home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / INTER52D.ZIP / 86BUGS.LST next >
File List  |  1994-11-03  |  119KB  |  3,005 lines

  1. (C) Copyright 1993, 1994 By Harald Feldmann Revision 04, Nov 3rd 1994.
  2.  
  3.  
  4.  
  5. Hamarsoft's 86BUGS list, (C) 1993/94 By Hamarsoft (R)
  6. ──────────────────────────────────────────────────────────────────────────────
  7.  
  8. The 86BUGS list, distributed with Ralf Brown's Interrupt list, is maintained
  9. and provided to you by Hamarsoft, the maker of the HAP & PAH datacompression
  10. program. Latest version of HAP & PAH is 3.14e. If you like this list you are
  11. encouraged to register the HAP 3.00 shareware program. You will receive
  12. the latest, registered, version of HAP 3.14e by air-mail on 3.5" diskette.
  13. FTP to garbo.uwasa.fi and get pc/arcers/hap300re.zip   for more info.
  14. ────────────────────────────────┬───────────────────────────────────────────
  15. To contact Hamarsoft, write to  │ or send e-mail over Internet to:
  16.                                 │ harald.feldmann@almac.co.uk               
  17. Hamarsoft,         New Address! │───────────────────────────────────────────
  18. Harald Feldmann,                │ or send e-mail to HARALD FELDMANN over
  19. P.o. Box 451,                   │ Ilink in the international COMPRESS echo
  20. 6400 AL  Heerlen,               │ The p.o. box will be maintained if e-mail
  21. The Netherlands                 │ should no longer be possible.
  22. ────────────────────────────────┴───────────────────────────────────────────
  23. Various people have contributed to this list. They are mentioned in a
  24. separate page, click on <acknowledgements> to see their names and e-mail
  25. addresses. These people are not employed by or affiliated with Hamarsoft.
  26.  
  27. Hamarsoft and all people who contributed to the 86BUGS list do not accept
  28. any liability whatsoever regarding the use, inability to use, correctness
  29. or completeness of the information presented in the 86BUGS list.
  30.  
  31. Attention authors: if you mention this list in your article or book, please
  32. send a courtesy copy to the P.o. box address by airmail. Thank you.
  33.  
  34. This is 86BUGS list revision level 04, issued November 3rd 1994.
  35. (C) Copyright 1993, 1994 By Harald Feldmann.
  36.  
  37.  
  38.  
  39.  
  40. Acknowledgements
  41. ──────────────────────────────────────────────────────────────────────────────
  42.  
  43. This file lists undocumented and buggy instructions of the Intel 80x86   
  44. family of processors as well as features of processors compatible with
  45. Intel products. Note that Intel does not support the special features and
  46. may decide to drop opcode variants and instructions in future products.  
  47. Wherever the notation 88,86,87,186,286,287,287xl,386,386sx,387,387sx,
  48. 486,486sx,487 and Pentium is used, Intel CPUs are referenced unless
  49. noted otherwise.
  50.  
  51. All mentioned trademarks and/or tradenames are owned by the respective   
  52. owners and are acknowledged.                                             
  53.  
  54. I would like to give credit to those who provided useful information or
  55. who in another way contributed to the 86BUGS list.
  56.  
  57. 9308 Chris Lueders  (chris_lueders@zaphod.fido.de) iAPX program & mul bugs
  58. 9311 Anthony Naggs  (amn@ubik.demon.co.uk) NEC differences and CPU tests
  59. 9407 Christian Ludloff (Ludwig-Kühn-Str. 15, 09123 Chemnitz, Germany)
  60.                     Discovered CPUID instruction on 486.
  61. 9410 Robert Mashlan (rmashlan@r2m.com) BOUND difference on NEC V20
  62. 9410 Anthony Naggs  (amn@ubik.demon.co.uk) POP CS & MOV CS on 86/88
  63.                     SETALC on NEC & i186 BOUND difference, NEC specific
  64.                     instructions.
  65. 9410 Christian Ludloff (see above for address) Pentium extensions (MSRs),
  66.                     INFO and STAT programs.
  67.  
  68. If you contributed, but are not listed, please send a note.
  69.  
  70.  
  71.  
  72.  
  73. AAA   Adjust After BCD Addition
  74. ──────────────────────────────────────────────────────────────────────────────
  75.  
  76. Mnemonic: AAA
  77. Opcode  : 37  (88=8, 86=8, 286=3, 386=4, 486=3 clocks)
  78. Bug in  : Different implementation in 88 and 86 versus 286+
  79.  
  80. Function:
  81. The 88 and 86 processors would not add a carry out of al into ah if an
  82. invalid operand would be in al (FF), the newer processors _will_, yielding
  83. different results for the same _invalid_ operand. Execution is effectively
  84. the same when valid operands are loaded.
  85. Highest 4 bits of AL are always cleared.
  86.  
  87.  
  88.  
  89.  
  90. AAD    Adjust After BCD Division
  91. ──────────────────────────────────────────────────────────────────────────────
  92.  
  93. Mnemonic: AAD
  94. Opcode  : D5 imm8  (88=60, 86=60, 286=14, 386=19, 486=14 clocks)
  95. Bug in  : Is an opcode variant on Intel's 88,86,286,386,486
  96.           Variant does not work on NEC's V-series, probably not on AMD CPUs
  97.  
  98. Function:                                   
  99. This instruction regularly performs the following action:
  100.   - unpacked BCD in AX   example (AX = 0104h)
  101.   - AL = AH * 10d + AL   (AL = 0eh )
  102.   - AH = 00              (AH = 00h )
  103.  
  104. The normal opcode decodes as follows: d5,0a                
  105. The instruction itself is an instruction plus operand. By replacing the 
  106. second byte with any number in the range 00 - ff you can build your own
  107. instruction AAD for various number systems in those ranges. For example
  108. by coding d5,10 you achieve an instruction that performs: 
  109.  
  110.   - AL = AH * 16d + AL.  
  111.   - AH = 00
  112.  
  113. This feature of Intel's chips can be used to determine whether there is
  114. a true Intel CPU installed in a system.
  115.  
  116. (NEC difference supplied by Anthony Naggs)
  117.  
  118.  
  119.  
  120.  
  121. AAM   Adjust After BCD Multiplication
  122. ──────────────────────────────────────────────────────────────────────────────
  123.  
  124. Mnemonic: AAM
  125. Opcode  : D4 imm8  (88=83, 86=83, 286=16, 386=17, 486=15 clocks)
  126. Bug in  : Is an opcode variant on Intel's 88,86,286,386,486
  127.  
  128. Function:                                                                 
  129. This instruction regularly performs the following action:   
  130.   - binary number in AL
  131.   - AH = AL / 10d
  132.   - AL = AL MOD 10d
  133.  
  134. Thus creating an unpacked BCD in AX. The normal opcode decodes as follows:
  135. d4,0a. The instruction itself is an instruction plus operand. By replacing
  136. the second byte with any number in the range 00 - ff you can build your own
  137. instruction AAM for various number systems in that range. For example by
  138. coding d4,07 you achieve an instruction that performs:
  139.   - binary number in AL
  140.   - AH = AL / 07d
  141.   - AL = AL MOD 07d                                                     
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148. AAS   Adjust After BCD Subtraction
  149. ──────────────────────────────────────────────────────────────────────────────
  150.  
  151. Mnemonic: AAS
  152. Opcode  : 3F
  153. Bug in  : Intel's documentation
  154.  
  155. Function:
  156. Adjusts result of two subtracted BCD numbers to form a valid new BCD number.
  157. Highest 4 bits of AL are always cleared.
  158.  
  159.  
  160.  
  161.  
  162. ADD4S   Addition of packed BCD strings (NEC V20/30 only)
  163. ──────────────────────────────────────────────────────────────────────────────
  164.  
  165. Mnemonic: ADD4S
  166. Opcode  : 0F 20  (7+19n clocks, n is the number of bytes per operand)
  167. Bug in  : Rarely documented, except in NEC manuals
  168.  
  169. Function:
  170. Adds the packed BCD string at DS:SI to the packed BCD string at ES:DI. The
  171. length of the string, in BCD digits, is specified in CL. Unlike Intel string
  172. operations CL, DI & SI are unchanged by the operation. The Zero Flag (ZF) is
  173. set if both operands are zero.  The Carry Flag (CF) and Overflow Flag (OF)
  174. appear to be set by the addition of the most significant digits.
  175.  
  176. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  177. instructions on 286+ CPUs.
  178.  
  179. (Supplied by Anthony Naggs)
  180.  
  181. See also SUB4S, CMP4S, ROL4, ROR4
  182.  
  183.  
  184.  
  185. BOUND  Checks register against limits
  186. ──────────────────────────────────────────────────────────────────────────────
  187.  
  188. Mnemonic: BOUND reg,mem
  189. Opcode  : 62 [mod:reg:r/m]
  190. Bug in  : NEC V20 handles it differently from Intel 286+. But apparently,
  191.           according to Intel documentation, equal to 186.
  192.  
  193. Function:
  194. Bound checks a register against limits and generates exception 5 if the
  195. value falls outside the limit. On NEC CPUs the mnemonic is apparently also
  196. referred to as 'CHKIND'.
  197. Note that the mem component refers to two consecutive memory locations, of
  198. size 'reg' which contain the lower and upper limit for the value in 'reg'
  199. as [low limit][high limit].
  200.  
  201. 'reg' size:     'mem' specifies address of:
  202.  
  203.     word            dword
  204.     dword           qword
  205.  
  206. Normally, on Intel 286+ CPUs, the exception saves the CS:IP pointing TO the
  207. BOUND instruction. On the NEC V20, the saved CS:IP point to the instruction
  208. following the BOUND instruction.
  209.  
  210. According to Intel's documentation the 186 handles this exception the same
  211. way the NEC does. It has been verified on a 486 that the CS:IP of BOUND on
  212. that CPU indeed points TO the instruction itself and not the following one.
  213.  
  214. Also, contrary to what one might expect, BOUND only allows word or dword
  215. registers to be tested. Byte registers are invalid.
  216.  
  217. (V20 supplied by Robert Mashlan)
  218. (186 difference & 'CHKIND' supplied by Anthony Naggs)
  219.  
  220.  
  221.  
  222.  
  223. Breakpoint errors while debugging
  224. ──────────────────────────────────────────────────────────────────────────────
  225.  
  226. Mnemonic: N/A
  227. Opcode  : N/A
  228. Bug in  : some 386, some 486
  229.  
  230. Function:
  231. Breakpoints are used in the process of debugging programs.
  232. On the 386+, debug registers may be used instead of a one byte opcode.
  233.  
  234. 386 specific debugging bugs occurring on some 386s:
  235. Breakpoints are missed under the following conditions:
  236.  
  237. - A data breakpoint set to a mem16 operand of a VERR, VERW, LSL or LAR while
  238.   the segment with selector at mem16 is not accessible.
  239.  
  240. - A data breakpoint is set to the write operand of a REP MOVS instruction
  241.   and the read cycle of the next iteration generates a fault.
  242.  
  243. - A code or data breakpoint is set on the instruction following a MOV or
  244.   POP to SS while the instruction needs more than two clocks.
  245.   (see <MOV> and <POP>)
  246.  
  247. Random breakpoints may occur under the following condition:
  248.  
  249. - Breakpoints set using debug registers DR0 to DR4 may produce spurious
  250.   breaks if breakpoints were enabled before a MOV from CR3, TR6 or TR7 took
  251.   place. These unreliable breaks may continue to occur until the next JMP
  252.   instruction is executed. A workaround would be to:
  253.   = disable breakpoints before any MOV from CR3, TR6 or TR7
  254.   = MOV the values
  255.   = perform a JMP
  256.   = enable breakpoints.
  257.  
  258. Single stepping is not disabled in the handler for a TSS fault if the code
  259. that caused the fault was being single-stepped and a task gate was used to
  260. handle the fault.
  261.  
  262. 486 specific debugging bugs occurring on some 486s:
  263.  
  264. A code breakpoint set on control transfer instructions (like CALL, RET, JMP
  265. etc.) will clear the lowest four bits of DR6 when the breakpoint is taken.
  266.  
  267. A code breakpoint set on an instruction immediately following a RETN, JCXZ,
  268. intrasegment indirect CALL (CALL word ptr [bx] for example) or
  269. intrasegment indirect JMP (JMP word ptr [bx] for example) will always be
  270. satisfied, even when the control instruction is taken. A breakpoint set at
  271. the target of these control transfer instructions will not be taken,
  272. even if control is transferred to them, because the buggy breakpoint sets
  273. the RF (Resume Flag). There is said to be no workaround other than to avoid
  274. the situation, however, coding a nop after the control transfer instruction
  275. and setting the breakpoint to the instruction following the nop may,
  276. according to my view, very well solve the problem. (untested)
  277.  
  278.  
  279.  
  280.  
  281. BRKEM   Break for emulation (NEC V20/30 only)
  282. ──────────────────────────────────────────────────────────────────────────────
  283.  
  284. Mnemonic: BRKEM   imm
  285. Opcode  : 0F FF imm  (38 clocks)
  286. Bug in  : Rarely documented, except in NEC manuals
  287.  
  288. Function:
  289. (8080 is written here as 8O8O to avoid visual confusion with the 8088).
  290. This is the basic instruction used to switch to 8O8O emulation mode.
  291. The BRKEM instruction is used in a similar way to an INT instruction,
  292. (referred to as BRK by NEC). The mode flag (MD) is set to zero, the Flags,
  293. CS & IP are pushed onto the stack then CS & IP are loaded from the
  294. specified interrupt vector.
  295.  
  296. In 8O8O emulation mode the V30 registers and flags are mapped to 8O8O
  297. registers and flags.
  298.  
  299.     General purpose register names:
  300.                     ┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
  301.     8O8O name───────│ A │ B │ C │ D │ E │ H │ L │ SP│ PC│
  302.     Intel x86 name──│ AL│ CH│ CL│ DH│ DL│ BH│ BL│ BP│ IP│
  303.     V30 name────────│ AL│ CH│ CL│ DH│ DL│ BH│ BL│ BP│ PC│
  304.                     └───┴───┴───┴───┴───┴───┴───┴───┴───┘
  305.  
  306.     Individual flag names:
  307.                     ┌───┬───┬───┬───┬───┐
  308.     8O8O name───────│ C │ Z │ S │ P │ AC│
  309.     Intel x86 name──│ CF│ ZF│ SF│ PF│ AF│
  310.     V30 name────────│ C │ Z │ S │ P │ AC│
  311.                     └───┴───┴───┴───┴───┘
  312.  
  313. In 8O8O emulation mode the segment used for instructions is determined
  314. by the CS (PS) register. The DS (DS0) register determines the segment
  315. used for data.
  316.  
  317. When an interrupt occurs during 8O8O emulation the CPU switches to native
  318. V30 mode to process the interrupt. When the interrupt handler is complete
  319. the IRET, (RETI in NEC nomenclature), will return to 8O8O emulation mode.
  320.  
  321. From 8O8O emulation mode RETEM (Return from Emulation, opcode ED FD) returns
  322. to native mode, setting MD flag and restoring flags, CS & IP from the native
  323. stack. Alternatively CALLN imm8 (Call Native, opcode ED ED imm) can be used
  324. to call native V30 interrupts, (just like a regular INT).
  325.  
  326. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  327. instructions on 286+ CPUs.
  328.  
  329. (Supplied by Anthony Naggs)
  330.  
  331.  
  332.  
  333.  
  334. BSF, Bit Scan Forward
  335. ──────────────────────────────────────────────────────────────────────────────
  336.  
  337. Mnemonic: BSF op1,op2
  338. Opcode  : 0F BC
  339. Bug in  : Intel's documentation
  340.  
  341. Function:
  342. Finds the first (lowest) bit set to 1 in op2, sets ZF=1 and returns the bit
  343. position in op1. If op2 is 0, ZF=0 and the value of op1 is undetermined,
  344. some 386's leave the old value in op1, some early 486's load garbage into
  345. op1 and later 486's leave op1 unchanged.
  346.  
  347.  
  348.  
  349.  
  350. BSWAP reg32   Byte Swap
  351. ──────────────────────────────────────────────────────────────────────────────
  352.  
  353. Mnemonic: BSWAP reg32
  354. Opcode  : 0F C8+reg# (00001111 11001rrr)
  355. Bug in  : 486
  356.  
  357. Function:
  358. Swaps all bytes in 32 bit registers, changing the sequence from ABCD to
  359. DCBA, handy for converting numbers to a CPU format where the byte order
  360. is reversed. Bug appears when BSWAP is not preceded by prefix 66h to
  361. indicate 32 bit registers in 16 bit mode or when it IS preceded by 66h
  362. in 32 bit mode.
  363. Do not use this instruction with 16 bit registers as operand.
  364. Results are undefined in that case. Use XCHG reg8,reg8 instead if you need
  365. to swap 2 bytes in a 16 bit register like AX.
  366.  
  367.  
  368.  
  369.  
  370. BT op1,op2  Bit Test
  371. ──────────────────────────────────────────────────────────────────────────────
  372.  
  373. Mnemonic: BT
  374. Opcode  : 0F A3 op1,op2
  375. Bug in  : No bug, avoid use on ports in 386, 486
  376.  
  377. Function:
  378. Basically copies bit(op2) from op1 into CY. Memory variant is more complex.
  379. Do not use on memory mapped I/O ports or memory operands that span into or
  380. lie completely within nonexistent memory.
  381. In the case of memory mapped I/O ports, use MOV and TEST instead.
  382.  
  383.  
  384.  
  385.  
  386. BTC op1,op2   Bit Test and Complement
  387. ──────────────────────────────────────────────────────────────────────────────
  388.  
  389. Mnemonic: BTC op1,op2
  390. Opcode  : 0F BB reg1,reg2
  391.           0F BA reg,mem
  392. Bug in  : No bug, avoid use on ports in 386, 486
  393.  
  394. Function:
  395. Basically copies bit(op2) from op1 into CY and complements bit(op2) of op1.
  396. Memory variant is more complex. Do not use on memory mapped I/O ports or
  397. memory operands that span into or lie completely within nonexistent memory.
  398. In the case of memory mapped I/O ports, use MOV and TEST instead.
  399.  
  400.  
  401.  
  402.  
  403. BTR op1,op2   Bit Test and Reset
  404. ──────────────────────────────────────────────────────────────────────────────
  405.  
  406. Mnemonic: BTR op1,op2
  407. Opcode  : 0F B3 [mod:reg:r/m]
  408.           0F BA [mod:110:r/m] imm8
  409. Bug in  : No bug, avoid use on ports in 386, 486
  410.  
  411. Function:
  412. Basically copies bit(op2) from op1 into CY and sets bit(op2) of op1 to 0.
  413. Memory variant is more complex. Do not use on memory mapped I/O ports or
  414. memory operands that span into or lie completely within nonexistent memory.
  415. In the case of memory mapped I/O ports, use MOV and TEST instead.
  416.  
  417.  
  418.  
  419.  
  420. BTS op1,op2   Bit Test and Set
  421. ──────────────────────────────────────────────────────────────────────────────
  422.  
  423. Mnemonic: BTS
  424. Opcode  : 0F BA [mod:101:r/m] imm8 / 0F AB [mod:reg:r/m]
  425. Bug in  : No bug, avoid use on ports in 386, 486
  426.  
  427. Function:
  428. Basically copies bit(op2) from op1 into CY and sets bit(op2) of op1 to 1.
  429. Memory variant is more complex. Do not use on memory mapped I/O ports or
  430. memory operands that span into or lie completely within nonexistent memory.
  431. In the case of memory mapped I/O ports, use MOV and TEST instead.
  432.  
  433.  
  434.  
  435.  
  436. Chip Step information for Intel CPUs
  437. ──────────────────────────────────────────────────────────────────────────────
  438.  
  439. CPUs are manufactured in models (like the 80386). While these models are
  440. manufactured, errors in the mask layout and mask design may become
  441. apparent. These errors may be corrected before a new batch of chips is
  442. made. To distinguish between these revisions an identification code is
  443. placed within the mask design on 386+ CPUs. By testing the CPU with CPUID
  444. or by performing a RESET, this information is copied to specific registers.
  445.  
  446. The register used to hold mask info after a RESET is DX (apparently also
  447. sometimes the high word of EDX on some 486s).
  448.  
  449. This page lists some component and revision ID's found in the DX register
  450. for the 386SX, 386DX, 486SX and 486DX models from Intel.
  451.  
  452.  
  453.         CPU:        DX:     Step:
  454.         386SX       2304h   A0
  455.                     2305h   B
  456.                     2306h   C
  457.                     2308h   D1
  458.  
  459.         386DX       0303h   B0 - B10
  460.                     0305h   D0
  461.                     0308h   D1 & D2
  462.  
  463.         486SX       0420h   A0
  464.  
  465.         486DX       0000h   A1
  466.                     0401h   Bn
  467.                     0302h   C0
  468.                     0404h   D0
  469.                     0410h   cAn
  470.                     0411h   cBn
  471.  
  472.  
  473.  
  474.  
  475. CLEAR1  Clears a specific bit to 0 (NEC V20/30 only)
  476. ──────────────────────────────────────────────────────────────────────────────
  477.  
  478. Mnemonic: CLEAR1 reg/mem,CL/immediate
  479. Opcode  : CLEAR1 r/m8,CL   : 0F 12 [mod:000:r/m]      (5/14 clocks)
  480.           CLEAR1 r/m8,imm3 : 0F 1A [mod:000:r/m] imm  (6/15 clocks)
  481.           CLEAR1 r/m16,CL  : 0F 13 [mod:000:r/m]      (5/14 clocks)
  482.           CLEAR1 r/m16,imm4: 0F 1B [mod:000:r/m] imm  (6/15 clocks)
  483.           CLEAR1 CY        : F8   (NEC nomenclature for Intel's CLC)
  484.           CLEAR1 DIR       : FC   (NEC nomenclature for Intel's CLD)
  485. Bug in  : Rarely documented, except in NEC manuals
  486.  
  487. Function:
  488. Clears the specified bit in the register/memory operand. The bit number (CL
  489. or immediate) is ANDed with 07 (for 8-bit operands) or 0F (for 16-bit
  490. operands) to get a valid bit number. No flags are affected by this
  491. operation, except by CLEAR1 CY and CLEAR1 DIR.
  492.  
  493. The first (smaller) clock count of each pair is for register operands.
  494. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  495. instructions on 286+ CPUs.
  496.  
  497. (Supplied by Anthony Naggs)
  498.  
  499. See Also: NECINS, EXT, TEST1, NOT1, SET1
  500.  
  501.  
  502.  
  503. CMP4S   Subtraction of packed BCD strings (NEC V20/30 only)
  504. ──────────────────────────────────────────────────────────────────────────────
  505.  
  506. Mnemonic: CMP4S
  507. Opcode  : 0F 26  (7+19n clocks, n is the number of bytes per operand)
  508. Bug in  : Rarely documented, except in NEC manuals
  509.  
  510. Function:
  511. Subtracts the packed BCD string at DS:SI from the packed BCD string at
  512. ES:DI, but does not store the result. The length of the string, in BCD
  513. digits, is specified in CL. Unlike Intel string operations CL, DI & SI are
  514. unchanged by the operation. The Zero Flag (ZF) is set if the result is zero.
  515. The Carry Flag (CF) and Overflow Flag (OF) appear to be set by the
  516. subtraction of the most significant digits.
  517.  
  518. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  519. instructions on 286+ CPUs.
  520.  
  521. (Supplied by Anthony Naggs)
  522.  
  523. See Also: ADD4S, SUB4S, ROL4, ROR4
  524.  
  525.  
  526.  
  527. CMPS Compare String Bytes, Word or Dword
  528. ──────────────────────────────────────────────────────────────────────────────
  529.  
  530. Mnemonic: CMPS
  531. Opcode  : A6 (Bytes)
  532.           A7 (Words)
  533.           66 A6 (Bytes)
  534.           66 A7 (DWords)
  535. Bug in  : Early 286 in protected mode
  536.  
  537. Function:
  538. Compares two strings in memory.
  539. Repeated version (REP CMPS) in early 286 protected mode has a bug that
  540. shows when, during execution, a segment limit exception or IO Privilege
  541. Level Exception occurs.
  542. In that case the exception handler sees the value of CX as it was at the
  543. start of the REP instruction. SI and DI however reflect the correct index
  544. of the elements currently scanned at the time of the exception.
  545.  
  546. Workaround: Do not scan beyond segment limits or into memory mapped I/O
  547. areas.
  548.  
  549.  
  550.  
  551.  
  552. CMPXCHG op1,op2   Compare and Exchange
  553. ──────────────────────────────────────────────────────────────────────────────
  554.  
  555. Mnemonic: CMPXCHG
  556. Opcode  : 0F B0 reg,mem/reg (Byte)
  557.           0F B1 reg,mem/reg (Word)
  558.           66 0F b0/b1 (Byte / DWord)
  559. Bug in  : pre-B step 486
  560.  
  561. Function:
  562. Compares the accumulator (8,16 or 32 bit form) with op1 by internally 
  563. subtracting op1 from the accumulator and setting ZF according to the result.
  564. If ZR, op2 is copied to op1, otherwise op1 is loaded into the accumulator.
  565.  
  566. On the A-step of the 486, this Mnemonic was coded using the opcodes for 
  567. the, discarded, A- to B0-step 386 instructions XBTS (a6) and IBTS (a7). 
  568. Because of software conflicts with software written for the early 386 DX the
  569. opcodes for the 486 were changed to the ones above starting with the B step.
  570.  
  571. Note that some 386 software won't run on older 386es and some 486 
  572. software will not run on early 486es when using this instruction.
  573.  
  574.  
  575.  
  576.  
  577. CPUID Identify CPU on 486 and higher CPUs
  578. ──────────────────────────────────────────────────────────────────────────────
  579.  
  580. Mnemonic: CPUID
  581. Opcode  : 0F A2
  582. Bug in  : Is undocumented for 486, seems not to work on tested AMD 486s
  583.           Officially introduced as a new instruction with the Pentium.
  584.  
  585. Function:
  586. Identifies CPU and revision information for the installed CPU. Note that
  587. Intel officially introduced CPUID only with the Pentium processor.
  588. It seems the instruction was unofficially introduced in the later
  589. 486 CPUs as well. Discovered by Christian Ludloff (see acknowledgements).
  590. Supported by the UMC U5S 486 clones as well.
  591.  
  592. Executing it on an early 486 yields an Invalid Opcode Exception.
  593. To safely use this instruction, an exception handler must be installed.
  594. A safer workaround though is to test whether the ID bit in EFLAGS is set.
  595. If so, the CPU supports CPUID. See <EFLAGS> image.
  596.  
  597. The instruction expects input in the EAX register and outputs information
  598. in the EAX, EBX, ECX and EDX registers.
  599.  
  600. Input:  EAX = 0000 0000 : Check CPU 486+ installed
  601.  
  602. Output: after CPUID:
  603.         EAX = 0000 0001 : OK, instruction supported
  604.         EBX = 756e 6547 : 'uneG'
  605.         EDX = 4965 6e69 : 'Ieni'
  606.         ECX = 6c65 746e : 'letn'
  607.         effectively the CPU says 'GenuineIntel'
  608.  
  609. Officially this returns a 'vendor string', which may indicate other than
  610. Intel strings for OEMs.
  611. The UMC U5S-33 returns 'UMC UMC UMC ' or ' UMC UMC UMC' (untested).
  612.  
  613. Input:  EAX = 0000 0001 : Obtain model specific information
  614.  
  615. Output: after CPUID:
  616.         EAX = RRRR RFMS : revision information
  617.             R = Reserved  Zero, but reserved
  618.             F = Family    (4=486, 5=Pentium)
  619.             M = Model     (3 on tested 486DX-2/66, 1 on tested Pentium/60)
  620.             S = Stepping  (5 on tested 486DX-2/66, 3 on tested Pentium/60)
  621.         EBX = RRRR RRRR
  622.             R = Reserved  Zero, but reserved
  623.         ECX = RRRR RRRR
  624.             R = Reserved  Zero, but reserved
  625.         EDX = xxxx xxxx : Bitmapped features, 1 means option available
  626.             Bit 0 =       FPU built-in (supported on 486 and Pentium)
  627.             Bit 1 =       V-86 mode extensions present
  628.             Bit 2 =       I/O breakpoints possible
  629.             Bit 3 =       4 MB paging supported
  630.             Bit 4 =       Time Stamp Counter present
  631.             Bit 5 =       Has Pentium compatible Model Specific Registers
  632.             Bit 6 =       Reserved (0)
  633.             Bit 7 =       Machine Check Exception supported (P5 only)
  634.             Bit 8 =       CMPXCHG8B supported (apparently Pentium only)
  635.             Bits 9-31     Reserved
  636.             Assume zero if bit is not mentioned.
  637.  
  638. Note that this instruction is not supported on all 486 CPUs. However,
  639. Christian Ludloff has tested it on some 486 DX and 486 SX models, in
  640. addition to the Pentium/60 and found them to be present on those machines.
  641. Any step and model information you find this instruction to run on is
  642. welcomed. Please forward it to Christian.
  643.  
  644. Apparently all new(er) Intel CPUs are equipped with (some) of these
  645. extensions, not just the Pentium.
  646.  
  647.  
  648.  
  649.  
  650. CR0-4 register layout (386+)
  651. ──────────────────────────────────────────────────────────────────────────────
  652.  
  653.     = CR0: Some bits remain from the Machine Status Word of the 286.
  654.  
  655.       Bit 31                         16                              0
  656.       ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┐
  657.       │P│C│N│r│r│r│r│r│r│r│r│r│r│A│r│W│r│r│r│r│r│r│r│r│r│r│n│e│t│E│m│p│
  658.       └┼┴┼┴┼┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴┼┴─┴┼┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴┼┴┼┴┼┴┼┴┼┴┼┘
  659.        │┌┘ │                     │   └───────────────────┐ │ │ │ │ │ │
  660.        ││┌─┘                     └─────────────────────┐ │ │ │ │ │ │ │
  661.        ││└NW Not Write through (1 if write through)    │ │ │ │ │ │ │ │
  662.        │└─CD Cache Disable (1 if disabled)             │ │ │ │ │ │ │ │
  663.        └──PE Paging Enabled                            │ │ │ │ │ │ │ │
  664.           AC Alignment mask (1=masked)─────────────────┘ │ │ │ │ │ │ │
  665.           WP Write Protect (1 if read-only pages protected)│ │ │ │ │ │
  666.           NE Numeric Error (1 if errors should be ignored)─┘ │ │ │ │ │
  667.           ET Extension Type (1=387 type FPU,0=287 type FPU)──┘ │ │ │ │
  668.           TS Task Switch (1=task switch has occurred)──────────┘ │ │ │
  669.           EP Emulate Processor Extension ────────────────────────┘ │ │
  670.              (1=execute exception 7 on FPU codes)                  │ │
  671.           MP Math Present (1=_FPU_ will handle FPU codes)──────────┘ │
  672.           PE Protection Enabled (1=Protected mode activated)─────────┘
  673.  
  674.       If EP=1 and MP=0, the FPU codes will be handled by software routines
  675.       via exception 7. Coprocessor emulators use this property.
  676.  
  677.     = CR1: Is reserved
  678.     = CR2: Linear 32-bit address of Page Fault
  679.  
  680.  
  681.  
  682.     = CR3: Page Directory Base Register (386+)
  683.  
  684.       Bit 31                         16                              0
  685.       ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┐
  686.       │x│x│x│x│x│x│x│x│x│x│x│x│x│x│x│x│x│x│x│x│r│r│r│r│r│r│r│p│P│r│r│r│
  687.       └┼┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴┼┴─┴─┴─┴─┴─┴─┴─┴┼┴┼┴─┴─┴─┘
  688.        └─────Page Directory Base Register────┘               │ │       PDBR
  689.        (used in the Paging process implemented on the 386+)  │ │
  690.                                                              │ │
  691.        Page-level Cache Disable (486+)───────────────────────┘ │       PCD
  692.        Page-level Writes Transparent (486+)────────────────────┘       PWT
  693.  
  694.  
  695.  
  696.     = CR4: Extended Machine Control (Pentium+)
  697.  
  698.       Bit 31                         16                              0
  699.       ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┐
  700.       │r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│r│M│r│p│D│T│P│V│
  701.       └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴┼┴─┴┼┴┼┴┼┴┼┴┼┘
  702.        Machine Check Enable (1=enabled)──────────────────┘   │ │ │ │ │ MCE
  703.        Page Size Extension (1=4 Mb paging instead of 4 Kb)───┘ │ │ │ │ PSE
  704.        Debugging Extension (1=breakpoints also valid for I/O)──┘ │ │ │ DE
  705.        Time Stamp instruction Disable (1=RDTSC only with CPL=0)──┘ │ │ TSD
  706.        Protected mode Virtual Interrupts (1=use VI flag in PM)─────┘ │ PVI
  707.        Virtual86 mode Virtual Interrupts (1=use VI flag in VM)───────┘ VME
  708.  
  709.  
  710.        The VME bit allows a V86 (or VM) task to use the 'virtual' interrupt
  711.        flag. Setting and clearing the interrupt flag (IF) in EFLAGS is no
  712.        longer intercepted by the V86 Monitor program (a very time consuming
  713.        procedure), instead, the Pentium+ sets and clears the VI flag in
  714.        EFLAGS, instead of the IF flag. This saves task switches to the
  715.        monitor to handle the CLI and STI instructions and thus a lot
  716.        of time in general purpose 8086 programs running in V86 mode.
  717.  
  718.        The PVI bit allows the same for Protected Mode procedures who would
  719.        otherwise need supervision by a different task. That is:
  720.        Tasks with CPL<0 may now call tasks with CPL=0 without crashing
  721.        the system, but only under specific circumstances.
  722.  
  723.        The TSD bit changes the CPL-sensitivity of the RDTSC (Read Time
  724.        Stamp Counter) instruction, a built-in CPU counter which is
  725.        incremented every internal clockpulse.
  726.        When TSD is 0, <RDTSC> is accessible for all CPL levels.
  727.        With TSD set to 1 however, RDTSC is available only to tasks with
  728.        CPL=0.
  729.  
  730.        The DE bit allows the Pentium+ to set breakpoints in I/O space
  731.        using the breakpoint registers. The R/W coding 10b is used to
  732.        indicate that the breakpoint is in I/O space on the Pentium+.
  733.        The 10b encoding was marked as 'invalid' for pre-Pentium CPUs.
  734.  
  735.        The PSE bit determines the size of the pages controlled by the
  736.        Paging Unit. With PSE = 0, the Paging mechanism uses 4 Kb pages.
  737.        With PSE set to 1 however, the Paging mechanism uses 4 Mb pages.
  738.  
  739.        The MCE bit is used to allow generation of a Machine Check Exception.
  740.        This exception is the result of a Parity error _within_ the Pentium
  741.        or an active BUSCHK signal (low) on pin T3 (upper right hand corner,
  742.        fourth pin from right, third from top when pin A1 is upper left
  743.        corner, TOP view). The exception is vectored through interrupt 18d
  744.        (or 12h). Execution after this exception may void system integrity.
  745.        The Machine Check Address register holds the value of the address
  746.        bus at the moment the event took place.
  747.        The Machine Check Type register holds the type of bus access at the
  748.        time the event took place.
  749.        Both these registers are internal 64 bit registers which can only be
  750.        read through the instruction <RDMSR> (Read Model Specific Register).
  751.        See also <WRMSR> (Write Model Specific Register).
  752.  
  753.  
  754.  
  755.  
  756. EFLAGS register layout (8088 to Pentium & NEC)
  757. ──────────────────────────────────────────────────────────────────────────────
  758.  
  759.       Bit 31                         16                              0
  760.       ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┐
  761.       │r│r│r│r│r│r│r│r│r│r│c│p│v│a│V│R│M│N│IOP│O│D│I│T│S│Z│r│A│r│P│r│C│
  762.       └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴┼┴┼┴┼┴┼┴┼┴┼┴┼┴┼┴┼┴─┴┼┴┼┴┼┴┼┴┼┴┼┴─┴┼┴─┴┼┴─┴┼┘
  763.                            │ │ │ │ │ │ │ │ │   │ │ │ │ │ │   │   │Carry
  764.       CPUID available ─────┘ │ │ │ │ │ │ │ │   │ │ │ │ │ │   │   Parity
  765.       Virtual Interrupt Pending│ │ │ │ │ │ │   │ │ │ │ │ │   └Aux carry
  766.       Virtual Interrupt flag ──┘ │ │ │ │ │ │   │ │ │ │ │ └──────── Zero
  767.       Alignment check ───────────┘ │ │ │ │ │   │ │ │ │ └────────── Sign
  768.       Virtual-86 mode enabled ─────┘ │ │ │ │   │ │ │ └ Trap (step mode)
  769.       Resume flag ───────────────────┘ │ │ │   │ │ └── Interrupt enable
  770.       Mode Flag ───────────────────────┘ │ │   │ └──── Direction (1=up)
  771.       Nested Task ───────────────────────┘ │   └────────────── Overflow
  772.                                            └── I/O privilege level 0..3
  773.  
  774.    Note: the Mode Flag is supported only on the NEC V20/30,
  775.    it is reserved on Intel CPUs.
  776.  
  777.    The diagram below shows the names for each bit as referenced to in most
  778.    books, along with the CPU in which the bit was =officially= introduced.
  779.  
  780.       Description:                  Name:   CPU introduced:
  781.  
  782.       CPUID available───────────────ID      Pentium
  783.       Virtual Interrupt Pending─────VIP     Pentium
  784.       Virtual Interrupt flag────────VI      Pentium
  785.       Alignment Check Flag──────────AC      486
  786.       Virtual-86 Mode Flag──────────VM      386
  787.       Resume Flag───────────────────RF      386
  788.       Mode Flag (8O8O emulation on)─MD      V20/V30 only
  789.       Nested Task───────────────────NT      286
  790.       I/O privilege level 0..3──────IOPL    286
  791.       Overflow Flag─────────────────OF       86
  792.       Direction Flag (1=up)─────────DF       86
  793.       Interrupt Flag (1=enabled)────IF       86
  794.       Trap Flag (single step mode)──TF       86
  795.       Sign Flag─────────────────────SF       86
  796.       Zero Flag─────────────────────ZF       86
  797.       Auxiliary carry Flag──────────AF       86
  798.       Parity Flag───────────────────PF       86
  799.       Carry Flag────────────────────CF       86
  800.  
  801. (8080 is written here as 8O8O to avoid visual confusion with the 8088).
  802. (Mode Flag supplied by Anthony Naggs)
  803.  
  804.  
  805.  
  806.  
  807. EXT   Extract bit field (NEC V20/30 only)
  808. ──────────────────────────────────────────────────────────────────────────────
  809.  
  810. Mnemonic: EXT reg8,reg8 / EXT reg8,imm4
  811. Opcode  : 0F 33 [mod:reg:r/m]  (26-55 clocks)
  812. Bug in  : Rarely documented, except in NEC manuals
  813.  
  814. Function:
  815. Loads AX with bit field data. Bit field length is specified by the lowest
  816. four bits of the second operand, more significant bits in AX are set to
  817. zero. DS:SI specify the first memory location to read, and the low 4-bits
  818. of the first operand specify the bit start position.  The bit field can
  819. cross a byte boundary. After each complete data transfer, SI and the first
  820. operand are automatically updated to point to the next bit field.
  821.  
  822. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  823. instructions on 286+ CPUs.
  824.  
  825. (Supplied by Anthony Naggs)
  826.  
  827. See Also: NECINS, TEST1, NOT1, CLEAR1, SET1
  828.  
  829.  
  830.  
  831. FPO2   Floating Point Operation 2 (NEC V20/30 only)
  832. ──────────────────────────────────────────────────────────────────────────────
  833.  
  834. Mnemonic: FPO2  fp-op / FPO2 fp-op,mem
  835. Opcode  : 0110011X [mod:XXX:r/m]  (2/11 clocks)
  836. Bug in  : Rarely documented, except in NEC manuals
  837.  
  838. Function:
  839. Intended to communicate with NEC maths co-processors. The NEC "FPO1" opcode
  840. corresponds to Intel's "ESC" prefix for co-processor instructions. Although
  841. data sheets exist for NEC maths co-processors, they have never been
  842. manufactured.
  843.  
  844. Note that the 386+ CPUs implement the opcodes 66 and 67 as Operand Size and
  845. Address Size prefixes respectively.
  846.  
  847. (Supplied by Anthony Naggs)
  848.  
  849.  
  850.  
  851.  
  852. HLT  Halt the processor
  853. ──────────────────────────────────────────────────────────────────────────────
  854.  
  855. Mnemonic: HLT
  856. Opcode  : F4
  857. Bug in  : No bug, handy use of instruction described below
  858.  
  859. Function:
  860. Halts the processor, CPU restarts only when external event takes place such
  861. as RESET activation, NMI request on NMI lines or maskable interrupt request
  862. on INTR when interrupts are enabled. 
  863. Handy to use with following piece of code:
  864.  
  865.           STI        ; enable interrupts
  866.      lazy:
  867.           HLT        ; suspend CPU internal bus clock
  868.           IN AL,60h  ; Key pressed !
  869.           CMP AL,whatever_key
  870.           JNE lazy   ; was not our key, just go back to sleep.
  871.  
  872. If the CPU is not going to be used for any processing tasks (hence is idle)
  873. one may execute the code above to cool down the CPU because it stops the
  874. internal CPU bus clock. It also saves (some) energy.
  875.  
  876.  
  877.  
  878.  
  879.  
  880. IBTS op1,op2   Insert Bit String
  881. ──────────────────────────────────────────────────────────────────────────────
  882.  
  883. Mnemonic: IBTS op1,op2
  884. Opcode  : 0F A7
  885. Bug in  : 386, 486 conflicting instruction opcode.
  886.  
  887. Function:
  888. Obsolete instruction which was introduced on the A step of the 386 and
  889. removed on the B1 step of the 386. The opcode a7 is used by the A step 486
  890. to function as part of the CMPXCHG instruction. Because of software
  891. conflicts (some compilers generated code for IBTS and its counterpart XBTS)
  892. Intel decided to change the opcode for CMPXCHG on the B step of the 486.
  893. Do NOT use IBTS in general purpose 386 or 486 applications.
  894.  
  895.  
  896.  
  897.  
  898. IMUL  Integer, signed, Multiply
  899. ──────────────────────────────────────────────────────────────────────────────
  900.  
  901. Mnemonic: IMUL op
  902.           IMUL op1,op2
  903.           IMUL op1,op2,op3
  904.           IMUL op1,op3
  905. Opcode  : F6w [mod:101:r/m] disp
  906. Bug in  : Apparently no bug, timing formula may be handy
  907.  
  908. Function:
  909. It is mentioned here because of the timing formula.
  910. The clocks used on 386 and 486 equal 9 or ceiling(log2(multiplier))+6.
  911. Depending on which one is bigger.
  912. Add an additional 3 clocks if multiplier is a memory operand.
  913.  
  914. See <MUL> for 32-bit MUL bugs.
  915.  
  916.  
  917.  
  918.  
  919. INS  Input String from IO port
  920. ──────────────────────────────────────────────────────────────────────────────
  921.  
  922. Mnemonic: INS, INSB, INSW, INSD
  923. Opcode  : AA, AB
  924. Bug in  : early 286, some 386, early 486, NEC conflicting mnemonic: INS
  925.  
  926. Function:
  927. Reads values from a port address in DX into a string at ES:DI or ES:EDI
  928. in memory. When used with the REPcondition prefix, CX or ECX contains the 
  929. number of values to read.
  930.  
  931. There is also a NEC specific instruction with the conflicting mnemonic INS,
  932. see <NECINS> or select <NEC specific instructions> from the mnemonic list
  933. page for more information regarding that instruction.
  934.  
  935. Bugs in the 286; 
  936. If, in protected mode, ES would contain a null selector or ES:DI would
  937. point beyond the segment limit when executing the single INS, causing
  938. exception 0dh, the 0d exception handler would point to the instruction
  939. following INS and not to it.
  940.  
  941. If, in protected mode, during the repeated version of the instruction, a
  942. segment limit or IOPL exception occurred, the exception handler would see
  943. the CX value as it was before the start of the instruction, DI would reflect
  944. the proper index at the time of the exception though. This type of bug
  945. also occurs with the CMPS instruction.
  946.  
  947. Bugs in the 386:
  948. The value of CX or ECX after the REPcondition version is not correct when
  949. the instruction is followed by a PUSH, POP or memory reference. After
  950. REP INS the value of CX, ECX is -1, not 0. Do not assume (E)CX to be 0.
  951.  
  952. When REP INS or INS is followed by an instruction that uses a different
  953. address size or when they are followed by an instruction that references
  954. the stack implicitly while the B bit of the SS descriptor is different than
  955. the address size used by the instruction, INS will not properly update
  956. the (E)DI and REP INS will not properly update the (E)CX register.
  957. The actual address size used will be the one of the instruction following
  958. the (REP) INS.
  959. A workaround for this bug is to code a NOP with the same address size as the
  960. INS right behind it by using the address size prefix byte 67h (when needed).
  961.  
  962. Bugs in the 486:
  963. Early 486 may hang if the INS destination address spans across a doubleword
  964. boundary, while not asserting BS16# or BS8#.
  965. To avoid this, always align the string at a doubleword.
  966.  
  967.  
  968.  
  969.  
  970. INS  (NECINS) Insert bit field (NEC V20/30 only)
  971. ──────────────────────────────────────────────────────────────────────────────
  972.  
  973. Mnemonic: INS reg8,reg8 / INS reg8,imm4
  974. Opcode  : 0F 31 [mod:reg:r/m]  (31-117 clocks)
  975. Bug in  : Rarely documented, except in NEC manuals
  976.  
  977. Function:
  978. Stores bit field data from AX into memory. Bit field length is specified by
  979. the lowest four bits of the second operand. ES:DI specify the first memory
  980. location to write, and the low 4-bits of the first operand specify the bit
  981. offset position. The bit field can cross a byte boundary. After each
  982. complete data transfer, DI and the first operand are automatically updated
  983. to point to the next bit field.
  984.  
  985. This mnemonic (INS) conflicts with the Intel mnemonic INS, which reads
  986. a string from an I/O port. This Intel instruction has bugs which are listed
  987. with the entry for <INS>. For clarity, this NEC version is referred to as
  988. "NECINS" where possible in this list.
  989.  
  990. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  991. instructions on 286+ CPUs.
  992.  
  993. (Supplied by Anthony Naggs)
  994.  
  995. See Also: EXT, TEST1, NOT1, CLEAR1, SET1
  996.  
  997.  
  998.  
  999. INVD Invalidate internal and external caches
  1000. ──────────────────────────────────────────────────────────────────────────────
  1001.  
  1002. Mnemonic: INVD
  1003. Opcode  : 0F 08
  1004. Bug in  : some 486
  1005.  
  1006. Function:
  1007. INVD tells the processor that all data in both the internal as well as the
  1008. external caches is invalid. Data held in external write-back caches is
  1009. discarded.
  1010.  
  1011. If on some 486's a cache line fill is in progress while the INVD instruction
  1012. is being executed, that line is NOT invalidated and the buffer contents
  1013. is moved into the cache. Valid cache lines are ALWAYS used to satisfy
  1014. read requests on all 486's, regardless whether the cache is enabled or not.
  1015.  
  1016. Workaround is to disable the cache prior to flushing it like this:
  1017.  
  1018.         MOV EAX,CR0
  1019.         OR  EAX,60000000h  ; cache disable bits
  1020.         PUSHFD
  1021.         CLI
  1022.         MOV BL,CS:here
  1023.         OUT dummyport,dummydata
  1024.         MOV CR0,EAX
  1025. here:
  1026.         INVD
  1027.         AND EAX,9fffffff   ; cache enable, write-through
  1028.         MOV CR0,EAX
  1029.         POPFD
  1030.  
  1031.  
  1032.  
  1033.  
  1034. JMP   Jump unconditionally.
  1035. ──────────────────────────────────────────────────────────────────────────────
  1036.  
  1037. Mnemonic: JMP dest
  1038. Opcode  : EB disp8
  1039. Bug in  : A to C0 step of 486
  1040.  
  1041. Function:
  1042. JMP transfers execution to a location within -127 to +128 bytes from the
  1043. jump instruction. The bug occurs when the jump causes a General Protection 
  1044. Violation while an NMI or INTR occur at exactly the same clockpulse.
  1045.  
  1046. Although very unlikely to occur, it is listed for completeness.
  1047.  
  1048.  
  1049.  
  1050.  
  1051. LAR   Load Access Rights (Protected Mode)
  1052. ──────────────────────────────────────────────────────────────────────────────
  1053.  
  1054. Mnemonic: LAR reg1,reg/mem
  1055. Opcode  : 0F 02
  1056. Bug in  : some 386
  1057.  
  1058. Function:
  1059. LAR Loads the Access rights of a descriptor in the Global Descriptor Table,
  1060. whose selector is reg/mem into reg1. When successful, ZF=1, otherwise ZF=0.
  1061.  
  1062. Some 386es allow access to selector 0 in the GDT leaving ZF=1.
  1063. Normally this should not be possible and produce the condition ZF=0.
  1064.  
  1065. Workaround would be to create an entry 0 in the GDT that consists of only
  1066. zeroes. This will cause access with a selector of 0 to fail and
  1067. produce ZF=0.
  1068.  
  1069. A data breakpoint set to the mem16 operand of LAR can be missed on some
  1070. 386es if the segment with the selector at mem16 is not accessible.
  1071. (see also <debugging>)
  1072.  
  1073.  
  1074.  
  1075.  
  1076. 286-LOADALL / 386-LOADALL
  1077. ──────────────────────────────────────────────────────────────────────────────
  1078.  
  1079. Mnemonic: LOADALL
  1080. Opcode  : 286 : 0F 05  (195 clocks)
  1081.           386+: 0F 07  (  ? clocks)
  1082. Bug in  : Is an undocumented opcode on 286,some 386,some early 486 ?
  1083.           Support for this instruction has been dropped with the 486.
  1084.  
  1085. Function: 
  1086. Loads virtually all processor registers with defined values from memory.
  1087. Initialises processor to specified state. Apparently aliased on the 286 by
  1088. opcode 0f 04.
  1089.  
  1090. The 286 LOADALL instruction reads a block of 102 bytes into the chip,
  1091. starting at address 000800 hex.
  1092.  
  1093.           Memory description for LOADALL read area on 286:
  1094.           (addresses are in hexadecimal, lengths in decimal)
  1095.  
  1096.           0800:  6   N/A
  1097.           0806:  2   MSW (Machine Status Word)
  1098.           0808: 14   N/A
  1099.           0816:  2   TR (Task Register)
  1100.           0818:  2   FLAGS (286 Flags)
  1101.           081a:  2   IP (Instruction Pointer)
  1102.           081c:  2   LDT (Local Descriptortable)
  1103.           081e:  2   DS (Data Segment)
  1104.           0820:  2   SS (Stack Segment)
  1105.           0822:  2   CS (Code Segment)               
  1106.           0824:  2   ES (Extra Segment)              
  1107.           0826:  2   DI (Destination Index)          
  1108.           0828:  2   SI (Source Index)               
  1109.           082a:  2   BP (Base Pointer)               
  1110.           082c:  2   SP (Stack Pointer)              
  1111.           082e:  2   BX (BX register)                
  1112.           0830:  2   DX (DX register)                
  1113.           0832:  2   CX (CX register)                
  1114.           0834:  2   AX (AX register)                
  1115.           0836:  6   ES cache (ES descriptor _cache_)
  1116.           083c:  6   CS cache (CS descriptor _cache_)
  1117.           0842:  6   SS cache (SS descriptor _cache_)
  1118.           0848:  6   DS cache (DS descriptor _cache_)
  1119.           084e:  6   GDTR (Global Descriptor Table)
  1120.           0854:  6   LDT cache (Local Descriptor_cache_)   
  1121.           085a:  6   IDTR (Interrupt Descriptor table)     
  1122.           0860:  6   TSS cache (Task State Segment _cache_)
  1123.  
  1124.           Descriptor caches layout:
  1125.           3 bytes    24 bit physical address of segment
  1126.           1 byte     access rights byte, same format as access right byte
  1127.                      in a regular descriptor. The 'present' bit now
  1128.                      represents a 'valid' bit. If this bit is cleared
  1129.                      (zero) the segment is invalid and accessing it will
  1130.                      trigger exception 0dh.
  1131.                      The DPL (Descriptor Privilege Level) fields of the CS
  1132.                      and SS descriptor caches determine the CPL
  1133.                      (Current Privilege Level).
  1134.           2 bytes    16 bit segment length limit.
  1135.  
  1136. This layout is the same for the GDTR and IDTR registers,
  1137. except that the access rights byte must be zero.
  1138.  
  1139. The register caches are internal CPU registers containing a copy of the last
  1140. 'composed' address and access information loaded for a particular register
  1141. in protected mode (e.g. ES). An outline of the basics of 286 protected
  1142. mode register caching and register layout is beyond the scope of this file
  1143.  
  1144.  
  1145. The 386 LOADALL loads 204 (dec) bytes from the address at ES:EDI and resumes
  1146. execution in the specified state.
  1147.  
  1148.           Memory description for LOADALL read area on 386+: 
  1149.           (addresses are in hexadecimal, lengths in decimal)
  1150.  
  1151.           relative offset: Bytes:   Registers:
  1152.           0000:  4   CR0
  1153.           0004:  4   EFLAGS
  1154.           0008:  4   EIP
  1155.           000c:  4   EDI
  1156.           0010:  4   ESI
  1157.           0014:  4   EBP
  1158.           0018:  4   ESP
  1159.           001c:  4   EBX
  1160.           0020:  4   EDX
  1161.           0024:  4   ECX
  1162.           0028:  4   EAX
  1163.           002c:  4   DR6
  1164.           0030:  4   DR7
  1165.           0034:  4   TR
  1166.           0038:  4   LDT
  1167.           003c:  4   GS (zero extended)
  1168.           0040:  4   FS (zero extended)
  1169.           0044:  4   DS (zero extended)
  1170.           0048:  4   SS (zero extended)
  1171.           004c:  4   CS (zero extended)
  1172.           0050:  4   ES (zero extended)  
  1173.           0054: 12   TSS descriptor cache
  1174.           0060: 12   IDT descriptor cache
  1175.           006c: 12   GDT descriptor cache
  1176.           0078: 12   LDT descriptor cache
  1177.           0084: 12   GS descriptor cache
  1178.           0090: 12   FS descriptor cache
  1179.           009c: 12   DS descriptor cache
  1180.           00a8: 12   SS descriptor cache
  1181.           00b4: 12   CS descriptor cache
  1182.           00c0: 12   ES descriptor cache
  1183.  
  1184.           Descriptor caches layout:
  1185.           1 byte     zero
  1186.           1 byte     access rights byte, same as 286
  1187.           2 bytes    zero
  1188.           4 bytes    32 bit physical base address of segment
  1189.           4 bytes    32 bit segment length limit
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195. LSL   Load Segment Limit
  1196. ──────────────────────────────────────────────────────────────────────────────
  1197.  
  1198. Mnemonic: LSL reg1,reg/mem
  1199. Opcode  : 0F 03
  1200. Bug     : some 386
  1201.  
  1202. Function:
  1203. Loads the limits of a segment in protected mode by reading GDT entry reg/mem
  1204. into reg1. Proper completion generates ZF=1, otherwise ZF=0.
  1205.  
  1206. Some 386es allow access to selector 0 in the GDT leaving ZF=1.
  1207. Normally this should not be possible and produce the condition ZF=0.
  1208.  
  1209. Workaround would be to create an entry 0 in the GDT that consists of only
  1210. zeroes. This will cause access with a selector of 0 to fail and
  1211. produce ZF=0.
  1212.  
  1213. Some 386es leave SP/ESP corrupted after successful completion of LSL, when
  1214. LSL is followed by an explicit stack reference, using instructions like
  1215. CALL, ENTER, LEAVE, IRET, RET, PUSH, POP, PUSHA, POPA, PUSHF and POPF.
  1216. System-induced exceptions or interrupts however do not corrupt SP/ESP in
  1217. that case. A workaround is to code a NOP after LSL.
  1218.  
  1219. A data breakpoint set to the mem16 operand of LSL can be missed on some
  1220. 386es if the segment with the selector at mem16 is not accessible.
  1221. (see also <debugging>)
  1222.  
  1223.  
  1224.  
  1225.  
  1226. MOV   Move data to and from registers and or memory
  1227. ──────────────────────────────────────────────────────────────────────────────
  1228.  
  1229. Mnemonic: MOV involving CRx, DRx or TRx, MOV to SS, CS
  1230. Opcode  : 0F 2n [mod:rrr:r/m], 8E [mod:sreg:r/m]
  1231. Bug in  : some 88,some 86,some 386,all 386,A to C0 step of 486
  1232.  
  1233. Function:
  1234. MOV Moves data in and out of (special) registers and memory.
  1235.  
  1236. Some _very early_ 88 and 86 processors do not disable interrupts following
  1237. a MOV sreg,reg. This causes them to crash when an interrupt uses the stack
  1238. between MOV SS,reg and MOV SP,op. These versions carry a copyright message
  1239. for 1978 on the package. Later, corrected revisions, carry both 1978 and
  1240. 1981 as the copyright year.
  1241. Normally interrupts would be disabled between the move to SS and execution
  1242. of the instruction following it on 88 and 86es. A workaround is to manually
  1243. disable the interrupts when reloading SS. The 286 and higher processors only
  1244. disable interrupts after a MOV SS, in contrast to earlier CPUs, including
  1245. the NECs, who do this with all MOV sreg,op instructions.
  1246.  
  1247. An unsolvable problem occurs when an unmaskable interrupt or exception
  1248. takes place while executing the instruction pair on an old 88 or 86.
  1249. There are conflicting messages though about this type of interrupts having
  1250. no effect on the bug.
  1251.  
  1252. On the 86 and 88, but not on the C-MOS versions 80C86 and 80C88, the
  1253. instruction MOV CS,op is valid and causes an unconditional jump.
  1254. The C-MOS versions, as well as the NEC V20 and V30 ignore this coding.
  1255. This may also be the case on the 186 but has not been tested.
  1256. The 286+ CPUs consider CS an invalid operand for this instruction and
  1257. generate exception 6 (Invalid opcode).
  1258. The opcode for the MOV CS,op is: 8e [mod:001:r/m] See also <POP CS>.
  1259.  
  1260. On some 386es, random breakpoint breaks occur from the debug registers
  1261. D0-D3 when a MOV from CR3, TR6 or TR7 is executed. This will continue until
  1262. after a jump instruction is executed. The actual contexts of D0-D3 is not
  1263. affected. Workaround is to disable breakpoints before the MOV from CR3,TR6
  1264. or TR7, execute a jmp right after the move and enabling breakpoints again.
  1265. See also <debugging>
  1266.  
  1267. On some 386es a MOV to SS may cause a code or data breakpoint set to the
  1268. instruction following the MOV to be missed if the instruction takes more
  1269. than two clocks. (see <debugging>)
  1270.  
  1271. On all 386es a MOV to or from CRx, TRx or DRx executes correctly regardless
  1272. of the mod field (the first two bits in the third byte of the opcode).
  1273. The mod should be 11b. Intel documentation for the 386 stated it was
  1274. undefined.
  1275. Some 386 assemblers and compilers may generate values other than 11b for
  1276. mod and fail on early 486es, causing an Invalid Opcode Exception, since they
  1277. do require the mod field to be correct. More recent 486es recognize the
  1278. aliased instructions as valid and execute them accordingly.
  1279.  
  1280. On all 386es, moves to or from DR4 and DR5 are aliased to DR6 and DR7.
  1281. On the early 486es these encodings are not recognized and generate an
  1282. Invalid Opcode Exception. More recent 486es do recognize these aliases and
  1283. execute them correctly.
  1284.  
  1285. On the A to C0 steps of the 486, loading TR5 with a reg32 operand may hang
  1286. the CPU if bits 0 and 1 (control bits) activate cache read, cache write or
  1287. flush. A workaround is:
  1288.  
  1289. JMP fetcher
  1290.  
  1291. ALIGN 16
  1292. fetcher:
  1293.      NOP
  1294.      IN AL,port   ; Note that this corrupts EAX...
  1295.      MOV TR5,EBX  ; EBX contained the new TR5 value.
  1296.      NOP
  1297.      NOP
  1298.  
  1299. On the A to C0 step of the 486 loading a value into CR0 which disables the
  1300. cache may corrupt the cache. Forcing a prefetch will avoid this.
  1301.  
  1302.      PUSHFD
  1303.      CLI
  1304.      MOV BL,CS:label
  1305.      MOV CR0,EAX
  1306.    label:
  1307.      POPFD
  1308.      NOP
  1309.  
  1310. Using EBX:
  1311. Note that using EBX under the Microsoft Windows 3.0 DOS box in standard mode
  1312. or after Microsoft Windows 3.0' termination after running standard mode, for
  1313. 32-bit addressing in real or virtual 86 mode, is likely to crash the system
  1314. due to the fact that apparently the Windows 3.0 DOS box trashes EBX while
  1315. servicing interrupts, turning bit 18 of EBX to 1 and thus causing unwanted
  1316. segment violation errors. Use of EBX in calculations is likely to cause
  1317. spurious errors and may yield unpredictable behaviour of your code under
  1318. the aforementioned circumstances.
  1319.  
  1320. (MOV CS,op for NEC and 88/86, C88/C86, & 1978 copyright message
  1321.  supplied by Anthony Naggs).
  1322.  
  1323.  
  1324.  
  1325.  
  1326. MOVS  Move string of bytes, words or doublewords in memory
  1327. ──────────────────────────────────────────────────────────────────────────────
  1328.  
  1329. Mnemonic: MOVSB / MOVSW / MOVSD
  1330. Opcode  : A4    / A5    / 66 A5
  1331. Bug in  : early 286 in PM, some 386
  1332.  
  1333. Function:
  1334. MOVS moves strings in memory. Possible units to move are byte, word and
  1335. doubleword. Typically the source is DS:(E)SI, the target ES:(E)DI
  1336.  
  1337. If the single instruction MOVS (not prefixed by REPx) is executed with a
  1338. NULL selector in ES or when ES:DI points beyond the segment limit while
  1339. executing the the single instruction, causing exception 0dh, the CS:IP
  1340. saved by the 0dh exception handler will point after the MOVS instruction,
  1341. instead of to it on some 286s.
  1342.  
  1343. If a segment limit exception or IOPL violation exception occurs during the
  1344. REPx prefixed form of MOVS in Protected Mode, some early 286 will reset CX
  1345. to its initial setting (before the REPx started) instead of showing CX as
  1346. it was at the time of the exception. SI and DI are not affected and show the
  1347. values they had at the time of the exception.
  1348.  
  1349. During debugging with breakpoints set, REP MOVS can cause data breakpoints
  1350. to be missed on some 386, see <debugging>.
  1351.  
  1352. If, on some 386es, MOVS is followed by an instruction which uses a different
  1353. address size, or by an instruction which implicitly references the stack
  1354. (like POP, PUSH, IRET, RET, CALL, ENTER, LEAVE, PUSHA, POPA, PUSHF and POPF)
  1355. while the D-bit for the stack is different from the current address size
  1356. used by the MOVS instruction, the destination register updated will depend
  1357. on the address size of the instruction that follows, rather than that of
  1358. the MOVS. This can result in the updating of only DI when EDI was meant
  1359. or EDI when only DI was meant.
  1360.  
  1361. The repeated form REPx MOVS has the same bug, but in addition to (E)DI,
  1362. also (E)SI is affected.
  1363.  
  1364. A workaround is to always code a NOP with the same address size after MOVS
  1365. and REPx MOVS.
  1366.  
  1367. Example:
  1368.  
  1369.     (16-bit code segment)
  1370.     MOVSW       ; 16-bit addressing MOVS
  1371.     NOP         ; 16-bit addressing NOP
  1372.     db 67h
  1373.     MOVSW       ; 32-bit addressing MOVS
  1374.     db 67h
  1375.     NOP         ; 32-bit addressing NOP
  1376.  
  1377.     (32-bit code segment)
  1378.     MOVSD       ; 32-bit addressing MOVS
  1379.     NOP         ; 32-bit addressing NOP
  1380.     db 67h
  1381.     MOVSD       ; 16-bit addressing MOVS
  1382.     db 67h
  1383.     NOP         ; 16-bit addressing NOP
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389. MUL  Unsigned Multiply 16 & 32-bit versions
  1390. ──────────────────────────────────────────────────────────────────────────────
  1391.  
  1392. Mnemonic: MUL reg
  1393. Opcode  : (66) F7 Ex
  1394. Bug in  : 386
  1395.  
  1396. Function:
  1397. MUL multiplies ax with a 16-bit operand to form a 32-bit result in dx:ax.
  1398. The 32-bit version multiplies eax with a 32-bit operand to form a 64-bit
  1399. result in edx:eax.
  1400.  
  1401. Some 386es have a problem which redirects output from the 32-bit MUL
  1402. to the wrong parts of the wrong registers.
  1403.  
  1404. Typically the following happens:
  1405.  
  1406. Properly operating 32-bit version:  Properly operating 16-bit version:
  1407.  
  1408.   EAX: 'A':'B'                        EAX: 'A':'B'
  1409.   EBX: 'C':'D'                        EBX: 'C':'D'
  1410.   EDX: 'E':'F'                        EDX: 'E':'F'
  1411.  
  1412. CD x AB gives a result in EF:AB     D x B gives a result in F:B
  1413.  
  1414. While executing the 32-bit MUL, the faulty CPU takes CD times AB and puts
  1415. the value it should have added to 'A' into 'F' while at the same time
  1416. adding the value it should have put into EF to AB.
  1417.  
  1418. No workaround other than to use 16-bit multiply.
  1419.  
  1420. Some 386's have a bug which generates incorrect values in 16-bit mode.
  1421. The iAPX program from IGEL (Chris Lueders) tests for this bug.
  1422.  
  1423. Intel apparently organized a replacement project to get the faulty chips
  1424. returned to factory for screening. After testing at Intel the faulty CPUs
  1425. were sold again to bulk buyers who installed them in 16-bit only machines.
  1426. These tested and failed chips carry the text "16-bit S/W only" or a single
  1427. sigma. The tested and passed chips carry a double sigma (ΣΣ) on the package.
  1428.  
  1429. (supplied by Chris Lueders)
  1430.  
  1431.  
  1432.  
  1433.  
  1434. NEC V20/V30 introduction
  1435. ──────────────────────────────────────────────────────────────────────────────
  1436.  
  1437. The NEC V series microprocessors are functionally similar to the 8086 design
  1438. which NEC licensed from Intel. The internal microcode and most NEC mnemonics
  1439. are different from Intel's, to avoid Intel copyright claims. Only the
  1440. NEC V20 & V30, pin compatible with 8088 & 8086 respectively, are usually
  1441. found in IBM compatible PCs.
  1442. The V20 and V30 are often supplied as an "upgrade kit" for PCs originally
  1443. equipped with an 88/86, as they execute most instructions in fewer clocks
  1444. and can be used at a higher clock rate than the Intel parts.
  1445.  
  1446. Occasionally single board PCs use the V40 & V50, which are based on the same
  1447. CPU core and have integrated peripheral functions. Other V series family
  1448. members diverge further from the Intel x86 series and are used in
  1449. controllers and instrumentation rather than PCs.
  1450.  
  1451. The V20 and V30 have four classes of extra instructions beyond those
  1452. present on the 86/88:
  1453. *   the instructions Intel introduced on the 186/188
  1454. *   unique instructions for the NEC V series
  1455. *   instructions to switch to/from 8O8O emulation mode
  1456. *   8O8O instructions in 8O8O emulation mode
  1457.  
  1458. (8080 is written here as 8O8O to avoid visual confusion with the 8088).
  1459. Since the 188/186 instructions are widely documented, and the 8O8O
  1460. instructions are of use only if you are writing a CP/M emulator or similar,
  1461. these instructions are not listed. The special instructions which can be
  1462. used in Intel x86 mode are listed in the <NEC mnemonics page>
  1463.  
  1464. (Supplied by Anthony Naggs)
  1465.  
  1466.  
  1467.  
  1468.  
  1469. NEC V20/V30-specific mnemonics list
  1470. ──────────────────────────────────────────────────────────────────────────────
  1471.  
  1472.   Bit field instructions:
  1473.  
  1474.   <INS>     (NECINS) Insert bit field  <EXT>    Extract bit field
  1475.   <TEST1>   Test a specific bit        <NOT1>   Invert a specific bit
  1476.   <CLEAR1>  Clear a specific bit       <SET1>   Set a specific bit
  1477.  
  1478.   Packed BCD support:
  1479.  
  1480.   <ADD4S>   Add packed BCD numbers     <SUB4S>  Subtract BCD strings
  1481.   <CMP4S>   Compare BCD strings (subtract without storing)
  1482.   <ROL4>    Rotate left 4 bits         <ROR4>   Rotate right 4 bits
  1483.  
  1484.   Instruction prefixes:
  1485.  
  1486.   <REPC>    Repeat while Carry         <REPNC>  Repeat while No Carry
  1487.  
  1488.   Floating point escape:               Start 8O8O emulation:
  1489.  
  1490.   <FPO2>    NEC equivalent of ESC      <BRKEM>  Break to 8O8O emulation mode
  1491.  
  1492.  
  1493. (Supplied by Anthony Naggs)
  1494.  
  1495.  
  1496.  
  1497.  
  1498. NOT1 Invert a specific bit (NOT operation) (NEC V20/30 only)
  1499. ──────────────────────────────────────────────────────────────────────────────
  1500.  
  1501. Mnemonic: NOT1 reg/mem,CL/immediate
  1502. Opcode  : NOT1 r/m8,CL   : 0F 16 [mod:000:r/m]      (4/18 clocks)
  1503.           NOT1 r/m8,imm3 : 0F 1E [mod:000:r/m] imm  (5/19 clocks)
  1504.           NOT1 r/m16,CL  : 0F 17 [mod:000:r/m]      (4/18 clocks)
  1505.           NOT1 r/m16,imm4: 0F 1F [mod:000:r/m] imm  (5/19 clocks)
  1506.           NOT1 CY        : F5  (NEC nomenclature for Intel's CMC)
  1507. Bug in  : Rarely documented, except in NEC manuals
  1508.  
  1509. Function:
  1510. NOTs the specified bit in the register/memory operand. The bit number (CL
  1511. or immediate) is ANDed with 07 (for 8-bit operands) or 0F (for 16-bit
  1512. operands) to get a valid bit number. No flags are affected by this
  1513. operation, except by NOT1 CY.
  1514.  
  1515. The first (smaller) clock count in each pair is for register operands.
  1516. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  1517. instructions on 286+ CPUs.
  1518.  
  1519. (Supplied by Anthony Naggs)
  1520.  
  1521. See Also: NECINS, EXT, TEST1, CLEAR1, SET1
  1522.  
  1523.  
  1524.  
  1525. POP  Pop register from stack
  1526. ──────────────────────────────────────────────────────────────────────────────
  1527.  
  1528. Mnemonic: POP
  1529. Opcode  : 51+reg (01011rrr) for general purpose registers, 0F for POP CS
  1530. Bug in  : POP CS is a valid opcode for 88, 86, invalid opcode for 186
  1531.           0F is prefix byte on NEC V20/30 and 286+
  1532.           POP SS and breakpoints on some 386
  1533.  
  1534. Function:
  1535. POP retrieves data from the stack while adjusting the stackpointer.
  1536.  
  1537. The 88 and 86 allow the encoding of 0f for POP CS. The NEC V20 and V30,
  1538. as well as the 286+ CPUs use that encoding to indicate new instructions.
  1539. On the 88 and 86 POP CS causes an unconditional jump. Executing 0F on
  1540. the 186 generates an Invalid opcode exception (6).
  1541.  
  1542. On some 386es a code or data breakpoint set to the instruction following
  1543. POP SS will not be taken if the instruction takes more than two clocks.
  1544. (see also <debugging>)
  1545.  
  1546. (POP CS supplied by Anthony Naggs)
  1547.  
  1548.  
  1549.  
  1550.  
  1551. POPA / POPAD Pop all general purpose registers
  1552. ──────────────────────────────────────────────────────────────────────────────
  1553.  
  1554. Mnemonic: POPA / POPAD
  1555. Opcode  : 61 / 66 61
  1556. Bug in  : some 386
  1557.  
  1558. Function:
  1559. POPA and POPAD pop all general purpose registers from the stack.
  1560. POPA pops 16-bit registers and POPAD pops 32-bit registers. The opcode is
  1561. the same. POPAD is POPA with an operand size prefix (66h).
  1562.  
  1563. If either POPA or POPAD is followed by an instruction which uses an
  1564. effective address calculation consisting of a base register and another
  1565. register other than (E)AX as an index, the contents of EAX is corrupted.
  1566.  
  1567. Also, if POPA or POPAD in 16-bit mode is followed by an instruction which
  1568. uses an effective address using EAX as a base or index, the CPU will hang.
  1569.  
  1570. The workaround is to always code a NOP after POPA as well as POPAD.
  1571.  
  1572.  
  1573.  
  1574.  
  1575. Prefetch queue, bus & cache parameters per CPU
  1576. ──────────────────────────────────────────────────────────────────────────────
  1577.  
  1578.               NEC         NEC          sx  dx  sx  dx
  1579.            88 V20 188  86 V30 186 286 386 386 486 486 Pentium
  1580.          ┌─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─────┐
  1581.   SPQB───┼ 4 │ 4 │ 4 │ 6 │ 6 │ 6 │ 6 │16 │16 │32 │32 │32 x 2 │
  1582.  NEBIPQ──┼ 1 │ 1 │ 1 │ 2 │ 2 │ 2 │ 2 │ 2 │ 4 │16 │16 │     ? │
  1583.  MPBRMP──┼ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │16b│16b│    32a│
  1584.   DIQL───┼ - │ - │ - │ - │ - │ - │ 3 │ 3 │ 3 │ - │ - │     ? │
  1585.   OCSKB──┼ - │ - │ - │ - │ - │ - │ - │ - │ - │ 8 │ 8 │ 8 x 2 │
  1586.   DBSB───┼ 8 │ 8 │ 8 │16 │16 │16 │16 │16 │32 │32 │32 │    64 │
  1587.   ABSB───┼20 │20 │20 │20 │20 │20 │24 │24 │32 │32 │32 │    32 │
  1588.          └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───────┘
  1589.   Legend:
  1590.  
  1591.    SPQB = Size of the Prefetch Queue (PQueue) in Bytes
  1592.  NEBIPQ = Number of Empty Bytes In PQueue to initiate prefetch cycle
  1593. *MPBRMP = Minimum possible number of Bytes to Read from Memory to Prefetch
  1594.    DIQL = Decoded Instruction Queue Length, measured in instructions
  1595.   OCSKB = On-chip Cache Size in KiloBytes
  1596.    DBSB = Data Bus Size in Bits
  1597.    ABSB = Address Bus Size in Bits
  1598.       - = None
  1599.       b = 16-byte burst mode cache line fill
  1600.       a = 32-byte burst mode cache line fill
  1601.  
  1602. * note that starting with the 486, prefetches are read from the cache.
  1603.   A cache line fill is performed in case of a cache miss and starts to
  1604.   read on paragraph boundaries only. A cache line on the 486 is 16 bytes
  1605.   in size. On the Pentium, a line fill starts on a boundary which lies
  1606.   at an even number of paragraphs (32-byte chunks).
  1607.  
  1608. (NEC & 188/186 prefetches supplied by Anthony Naggs)
  1609.  
  1610.  
  1611.  
  1612.  
  1613. PUSH  Pushes value or register onto the stack.
  1614. ──────────────────────────────────────────────────────────────────────────────
  1615.  
  1616. Mnemonic: PUSH reg / PUSH mem
  1617. Opcode  : 01010rrr / FF [mod:110:r/m]
  1618. Bug in  : PUSH (E)SP different operation on 286+, PUSH mem on some 286 in PM
  1619.  
  1620. Function:
  1621. PUSH pushes a value or register onto the stack.
  1622.  
  1623. Normally, the value pushed is placed in the location pointed to by SS:SP
  1624. (or SS:ESP on 386+), after which (E)SP is decremented by a word or dword.
  1625.  
  1626. When pushing any register or value, the difference between 286+ and previous
  1627. CPUs is not visible and causes no problems.
  1628. However, when pushing SP (or ESP on 386+) the value pushed is different
  1629. between 286 and previous CPUs.
  1630.  
  1631. On CPUs prior to the 286, SP would be decremented and then pushed.
  1632. On 286+ however, SP gets pushed and then decremented, leaving a different
  1633. value on the stack for SP. On the 386+ the same is in effect when
  1634. pushing ESP
  1635.  
  1636. If PUSH mem on the 286 in Protected Mode causes a stack limit violation -
  1637. exception 0bh, the saved CS:IP will point _after_ the PUSH instead of _to_
  1638. it on some early 286.
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644. RDTSC Read Time Stamp Counter
  1645. ──────────────────────────────────────────────────────────────────────────────
  1646.  
  1647. Mnemonic: RDTSC
  1648. Opcode  : 0F 31
  1649. Bug in  : Poorly documented for Pentium Processor
  1650.  
  1651. Function:
  1652. RDTSC reads a Pentium internal 64 bit register which is being incremented
  1653. from 0000 0000 0000 0000 at every CPU internal clockcycle. Note that this
  1654. gives a clockcycle-accurate timer with a range of more than 8800 years at
  1655. 66 Mhz...
  1656.  
  1657. The instruction places the counter in the EDX:EAX register pair.
  1658.  
  1659.  
  1660.  
  1661.  
  1662. REPNC / REPC  Repeat next string operation while (No) Carry
  1663. ──────────────────────────────────────────────────────────────────────────────
  1664.  
  1665. Mnemonic: REPC / REPNC
  1666. Opcode  : 65   / 64 (  ? clocks) (GS/FS override on 386+)
  1667. Bug in  : Rarely documented except in NEC manuals, invalid on Intel CPUs
  1668.           Conflicting opcode for GS and FS segment override for 386+
  1669.  
  1670. Function:
  1671. REPC repeats the following string instruction while the Carry Flag is set.
  1672. REPNC repeats the following string instruction while the Carry Flag is
  1673. clear. CX should hold the maximum number of iterations,
  1674. just as with REPZ/REPNZ.
  1675.  
  1676. Note that since these instructions works with the Carry Flag, they have no
  1677. special effect on MOVS and LODS. A simple REP should be used in these cases.
  1678.  
  1679. These instructions are NEC specific. They are not implemented on the Intel
  1680. CPUs. Note that the 386+ implements the listed opcodes 64 and 65 for the
  1681. segment override instructions FS and GS respectively.
  1682.  
  1683. If your software will run on a NEC, they may be handy.
  1684.  
  1685.  
  1686.  
  1687.  
  1688. ROL4   Rotate left 4 bits (NEC V20/30 only)
  1689. ──────────────────────────────────────────────────────────────────────────────
  1690.  
  1691. Mnemonic: ROL4  reg8/mem8
  1692. Opcode  : 0F 28 [mod:000:r/m]  (25/28 clocks)
  1693. Bug in  : Rarely documented, except in NEC manuals
  1694.  
  1695. Function:
  1696. Rotates a BCD digit (4 bits) left out of the operand, through the low 4 bits
  1697. of AX.
  1698.  
  1699.                     AL                   reg/mem
  1700.              7 . . . . . . 0         7 . . . . . . 0
  1701.             ┌───────┬───────┐       ┌───────┬───────┐
  1702.             │       │       │<──────┤       │       │<───┐
  1703.             └───────┴───┬───┘       └───────┴───────┘    │
  1704.                         └──>─────────────────────────────┘
  1705.  
  1706. The first (smaller) clock count is for a register operand.
  1707. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  1708. instructions on 286+ CPUs.
  1709.  
  1710. (Supplied by Anthony Naggs)
  1711.  
  1712. See Also: ADD4S, SUB4S, CMP4S, ROR4
  1713.  
  1714.  
  1715.  
  1716. ROR4   Rotate right 4 bits (NEC V20/30 only)
  1717. ──────────────────────────────────────────────────────────────────────────────
  1718.  
  1719. Mnemonic: ROR4  reg8/mem8
  1720. Opcode  : 0F 2A [mod:000:r/m]  (29/33 clocks)
  1721. Bug in  : Rarely documented, except in NEC manuals
  1722.  
  1723. Function:
  1724. Rotates a BCD digit (4 bits) right out of the operand, through the low 4
  1725. bits of AX.
  1726.  
  1727.                     AL                   reg/mem
  1728.              7 . . . . . . 0         7 . . . . . . 0
  1729.             ┌───────┬───────┐       ┌───────┬───────┐
  1730.             │       │       ├──────>│       │       ├>───┐
  1731.             └───────┴───┬───┘       └───────┴───────┘    │
  1732.                         └──<─────────────────────────────┘
  1733.  
  1734. The first (smaller) clock count is for a register operand.
  1735. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  1736. instructions on 286+ CPUs.
  1737.  
  1738. (Supplied by Anthony Naggs)
  1739.  
  1740. See Also: ADD4S, SUB4S, CMP4S, ROL4
  1741.  
  1742.  
  1743.  
  1744. SET1 Set a specific bit (NEC V20/30 only)
  1745. ──────────────────────────────────────────────────────────────────────────────
  1746.  
  1747. Mnemonic: SET1 reg/mem,CL/immediate
  1748. Opcode  : SET1 r/m8,CL   : 0F 14 [mod:000:r/m]      (4/13 clocks)
  1749.           SET1 r/m8,imm3 : 0F 1C [mod:000:r/m] imm  (5/14 clocks)
  1750.           SET1 r/m16,CL  : 0F 15 [mod:000:r/m]      (4/13 clocks)
  1751.           SET1 r/m16,imm4: 0F 1D [mod:000:r/m] imm  (5/14 clocks)
  1752.           SET1 CY        : F9   (NEC nomenclature for Intel's STC)
  1753.           SET1 DIR       : FD   (NEC nomenclature for Intel's STD)
  1754. Bug in  : Rarely documented, except in NEC manuals
  1755.  
  1756. Function:
  1757. Sets the specified bit in the register/memory operand. The bit number (CL
  1758. or immediate) is ANDed with 07 (for 8-bit operands) or 0F (for 16-bit
  1759. operands) to get a valid bit number. No flags are affected by this
  1760. operation, except the Carry and Direction Flag with SET1 CY and SET1 DIR.
  1761.  
  1762. The first (smaller) clock count in each pair is for register operands.
  1763. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  1764. instructions on 286+ CPUs.
  1765.  
  1766. (Supplied by Anthony Naggs)
  1767.  
  1768. See Also: NECINS, EXT, TEST1, NOT1, CLEAR1
  1769.  
  1770.  
  1771.  
  1772. SETALC   Set AL according to Carry
  1773. ──────────────────────────────────────────────────────────────────────────────
  1774.  
  1775. Mnemonic: SETALC
  1776. Opcode  : D6  (  ? clocks)
  1777. Bug in  : Is an undocumented opcode on 88,86,286,386,486
  1778.           Does not work on NEC and Sony V20+ (is alias for XLATB there)
  1779.                                    
  1780. Function:                          
  1781. This instruction copies the Carry Flag to the AL register without changing
  1782. any flags. In case of a CY, AL becomes ffh. When the Carry Flag is cleared,
  1783. AL becomes 00.
  1784.  
  1785. (NEC & Sony difference, and 86/88 availability supplied by Anthony Naggs)
  1786.  
  1787.  
  1788.  
  1789.  
  1790. Shift and Rotate operand limitations
  1791. ──────────────────────────────────────────────────────────────────────────────
  1792.  
  1793. Mnemonic: SHL, SAL, SHR, SAR, ROL, RCL, ROR, RCR, and all xxxD variants
  1794. Opcode  : various
  1795. Bug in  : 186+ will AND the shift- or rotate count with 1f before execution
  1796.           NEC V20 and V30 act like 88 / 86 and do not limit the count.
  1797.                                    
  1798. Function:
  1799. The instructions mentioned above will limit the actual number of bits
  1800. shifted or rotated to the number of bits to be shifted AND 1f. The
  1801. remainder is actually shifted or rotated. A shift of 21h will actually be
  1802. a shift of 1.
  1803.  
  1804. This is also the case for the double shifts on 386+.
  1805.  
  1806. (186 and NEC difference supplied by Anthony Naggs)
  1807.  
  1808.  
  1809.  
  1810.  
  1811. SUB4S   Subtraction of packed BCD strings (NEC V20/30 only)
  1812. ──────────────────────────────────────────────────────────────────────────────
  1813.  
  1814. Mnemonic: SUB4S
  1815. Opcode  : 0F 22  (7+19n clocks, n is the number of bytes per operand)
  1816. Bug in  : Rarely documented, except in NEC manuals, is conflicting opcode
  1817.           on 386+ (MOV)
  1818.  
  1819. Function:
  1820. Subtracts the packed BCD string at DS:SI from the packed BCD string at
  1821. ES:DI. The length of the string, in BCD digits, is specified in CL. Unlike
  1822. Intel string operations CL, DI & SI are unchanged by the operation. The
  1823. Zero Flag (ZF) is set if the result is zero. The Carry Flag (CF) and
  1824. Overflow Flag (OF) appear to be set by the subtraction of the most
  1825. significant digits.
  1826.  
  1827. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  1828. instructions on 286+ CPUs.
  1829.  
  1830. (Supplied by Anthony Naggs)
  1831.  
  1832. See Also: ADD4S, CMP4S, ROL4, ROR4
  1833.  
  1834.  
  1835.  
  1836. TEST1 Test a specific bit (NEC V20/30 only)
  1837. ──────────────────────────────────────────────────────────────────────────────
  1838.  
  1839. Mnemonic: TEST1 reg/mem,CL/immediate
  1840. Opcode  : TEST1 r/m8,CL   : 0F 10 [mod:000:r/m]      (3/12 clocks)
  1841.           TEST1 r/m8,imm3 : 0F 18 [mod:000:r/m] imm  (4/13 clocks)
  1842.           TEST1 r/m16,CL  : 0F 11 [mod:000:r/m]      (3/12 clocks)
  1843.           TEST1 r/m16,imm4: 0F 19 [mod:000:r/m] imm  (4/13 clocks)
  1844. Bug in  : Rarely documented, except in NEC manuals, opcodes 0f 10 and
  1845.           0f 11 are conflicting opcodes on 386+ (MOV aliases for 88-8b)
  1846.  
  1847. Function:
  1848. Tests the specified bit in the register/memory operand, if it is zero the
  1849. Z flag is set otherwise it is cleared. The bit number (CL or immediate)
  1850. is ANDed with 07 (for 8-bit operands) or 0F (for 16-bit operands) to get a
  1851. valid bit number.
  1852.  
  1853. The first (smaller) clock count in each pair is for register operands.
  1854. Note that 0F is treated as <POP CS> on the 88/86 and prefixes newer
  1855. instructions on 286+.
  1856.  
  1857. (Supplied by Anthony Naggs)
  1858.  
  1859. See Also: NECINS, EXT, NOT1, CLEAR1, SET1
  1860.  
  1861.  
  1862.  
  1863. UNKNOWN opcode, info wanted
  1864. ──────────────────────────────────────────────────────────────────────────────
  1865.  
  1866. Mnemonic: UNKNOWN
  1867. Opcode  : 0F 04  (  ? clocks)
  1868. Bug in  : Is an unknown opcode on 286                 
  1869.  
  1870. Function:
  1871. Exact purpose unknown, when executed it hangs the machine, likely bringing
  1872. it into protected mode, anyone with a hardware debugger may check to find
  1873. out. This instruction is likely to be an alias for the LOADALL on the 286.
  1874. It does not generate an exception. >> info wanted <<
  1875.  
  1876.  
  1877.  
  1878.  
  1879. VERR / VERW Verify a segment selector for Reading or Writing
  1880. ──────────────────────────────────────────────────────────────────────────────
  1881.  
  1882. Mnemonic: VERR op / VERW op
  1883. Opcode  : 0F 00 [mod:100:r/m] / 0f 00 [mod:101:r/m]
  1884. Bug in  : some 386
  1885.  
  1886. Function:
  1887. VERR verifies that the segment selector in memory, pointed to by op, is
  1888. readable and accessible with the current privilege level (CPL).
  1889. If so, the Zero Flag is set to 1, if not, the Zero Flag is cleared.
  1890.  
  1891. VERW verifies that the segment selector in memory, pointed to by op, is
  1892. writable and accessible with the current privilege level (CPL).
  1893. If so, the Zero Flag is set to 1, if not, the Zero Flag is cleared.
  1894.  
  1895. On some 386 both instructions allow a NULL selector to be specified,
  1896. accessing selector zero in the GDT, instead of failing unconditionally with
  1897. ZF=0, which would be the normal procedure. Workaround is to fill descriptor
  1898. zero in the GDT with all zeroes. Accessing it will then always fail and
  1899. produce the desired effect.
  1900.  
  1901. On some 386 both VERR and VERW can hang the CPU until an INTR, NMI or RESET
  1902. occurs. This bug occurs when there is no memory operand, JMP or CALL
  1903. instruction in the <prefetch queue> along with the VERR or VERW.
  1904. Workaround is to code a JMP or Jcondition instruction right after the VERR
  1905. or VERW, with the added condition that _the last byte_ of the VERR / VERW
  1906. and the _complete_ JMP instruction must fit in the same aligned doubleword.
  1907.  
  1908. A data breakpoint set to the mem16 operand of either VERR or VERR can be
  1909. missed on some 386es if the segment with the selector at mem16 is not
  1910. accessible. (see also <debugging>)
  1911.  
  1912.  
  1913.  
  1914.  
  1915. WBINVD Write back & invalidate both internal & external caches
  1916. ──────────────────────────────────────────────────────────────────────────────
  1917.  
  1918. Mnemonic: WBINVD
  1919. Opcode  : 0F 09
  1920. Bug in  : some 486
  1921.  
  1922. Function:
  1923. WBINVD tells the processor that all data in both the internal as well as the
  1924. external caches is invalid. Data held in external write-back caches is
  1925. written back to memory before the flush.
  1926.  
  1927. If on some 486's a cache line fill is in progress while the WBINVD
  1928. instruction is being executed, that line is NOT invalidated and the buffer
  1929. contents is moved into the cache. Valid cache lines are ALWAYS used to
  1930. satisfy read requests on all 486's, regardless whether the cache is enabled
  1931. or not.
  1932.  
  1933. Workaround is to disable the cache prior to flushing it like this:
  1934.  
  1935.         MOV EAX,CR0
  1936.         OR  EAX,60000000h  ; cache disable bits
  1937.         PUSHFD
  1938.         CLI
  1939.         MOV BL,CS:here
  1940.         OUT dummyport,dummydata
  1941.         MOV CR0,EAX
  1942. here:
  1943.         WBINVD
  1944.         AND EAX,9fffffff   ; cache enable, write-through
  1945.         MOV CR0,EAX
  1946.         POPFD
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952. Write / Read Model Specific Register (Pentium+ compatible)
  1953. ──────────────────────────────────────────────────────────────────────────────
  1954.  
  1955. Mnemonic: WRMSR / RDMSR
  1956. Opcode  : 0F 30 / 0f 32
  1957. Bug in  : Are minimally documented opcodes for Pentium+ compatible CPUs
  1958.  
  1959. Function:
  1960. It should be possible to use the WRMSR & RDMSR instructions on any CPU which
  1961. A: supports the CPUID instruction and
  1962. B: has the extension bit 5 in the feature bitmap of EDX set after
  1963.    executing function 1 (EAX=1) with CPUID.
  1964.  
  1965. WRMSR writes to a Model Specific Register. EDX:EAX contain the value to
  1966. write into the register whose number is given in ECX.
  1967.  
  1968. RDMSR reads from a Model Specific Register. EDX:EAX will receive the value
  1969. from the MSR whose number is given in ECX.
  1970.  
  1971.   List of Model Specific Registers:
  1972.  
  1973.   00h   Machine Check Exception-Address register (Read-only)
  1974.   01h   Machine Check Exception-Type register (Read-only)
  1975.   02h   Unknown
  1976.   ..
  1977.   0dh   Unknown
  1978.   0eh   Test register T12
  1979.   0fh   Unknown
  1980.   10h   Time Stamp Counter (See RDTSC)
  1981.   11h   Counter / Event Selection register (See CESR Map)
  1982.   12h   Counter #0 (40 bit resolution)
  1983.   13h   Counter #1 (40 bit resolution)
  1984.  
  1985.  
  1986.       CESR Map. Note that CESR is a 64-bit register, of which only the
  1987.       bottom 32 bits are currently known to be used.
  1988.  
  1989.       Bit 31                         16                              0
  1990.       ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┐
  1991.       │r│r│r│r│r│r│r│c│3│2│t│t│t│t│t│t│r│r│r│r│r│r│r│C│3│2│T│T│T│T│T│T│
  1992.       └─┴─┴─┴─┴─┴─┴─┴┼┴┼┴┼┴┼┴─┴─┴─┴─┴┼┴─┴─┴─┴─┴─┴─┴─┴┼┴┼┴┼┴┼┴─┴─┴─┴─┴┼┘
  1993.                      │ │ │ └─────┬───┘               │ │ │ └────┬────┘
  1994.       Counting method┘ │ └─────┐ │ ──────────────────┘ │ │      │
  1995.       Allow counting in CPL3   │ │ ────────────────────┘ │      │
  1996.       Allow counting in CPL0-2─┘ │ ──────────────────────┘      │
  1997.       Event type (what to count)─┘ ─────────────────────────────┘
  1998.       (see list below)
  1999.        └──────────┬──────────────────┘ └────────────┬────────────────┘
  2000.       Counter #1:─┘                     Counter #0:─┘
  2001.  
  2002.       Counting methods:         1= count CPU cycles     0= count events
  2003.       Allow count in CPL3:      1= Yes                  0= No
  2004.       Allow count in CPL0-2:    1= Yes                  0= No
  2005.  
  2006.       Event Type List:
  2007.         00h data read
  2008.         01h data write
  2009.         02h data TLB miss
  2010.         03h data read miss
  2011.         04h data write miss
  2012.         05h Write (hit) to M (modified) or E (exclusive) cacheline
  2013.             (MESI protocol)
  2014.         06h data cache lines written back
  2015.         07h data cache snoops
  2016.         08h data cache snoop hits
  2017.         09h memory accesses in both pipes
  2018.             (cumulative ?)
  2019.         0ah data bank access conflicts (U & V pipe access same data line in
  2020.             data cache).
  2021.         0bh misaligned data memory references
  2022.         0ch code read
  2023.         0dh code TLB miss
  2024.         0eh code cache miss
  2025.         0fh any segment register load
  2026.         10h segment descriptor cache accesses
  2027.         11h segment descriptor cache hits
  2028.         12h branches
  2029.         13h Branch Target Buffer (BTB) hits
  2030.         14h taken branch or BTB hit
  2031.         15h pipeline flushes
  2032.         16h instructions executed
  2033.         17h instructions executed in V pipe
  2034.         18h bus utilization (apparently events in which the CPU has to wait
  2035.             for bus access).
  2036.         19h pipeline stalled by write backups
  2037.         1ah pipeline stalled by data memory read
  2038.         1bh pipeline stalled by write to M or E line
  2039.         1ch locked bus cycle (for instance during xchg)
  2040.         1dh I/O read or write cycles
  2041.         1eh noncacheable memory references
  2042.         1fh pipeline stalled by Address Generation Interlock (AGI)
  2043.         20h unknown
  2044.         21h unknown
  2045.         22h floating point operations
  2046.         23h breakpoint 0 match
  2047.         24h breakpoint 1 match
  2048.         25h breakpoint 2 match
  2049.         26h breakpoint 3 match
  2050.         27h hardware interrupts
  2051.         28h data read or data write
  2052.         29h data read miss or data write miss
  2053.  
  2054.     (All info provided by Christian Ludloff)
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060. All mentioned x86 CPU instructions by Mnemonic
  2061. ──────────────────────────────────────────────────────────────────────────────
  2062.  
  2063.   Click on any instruction mnemonic to see details.
  2064.   See <Breakpoint errors> for CPU bugs relating to debugging.
  2065.   See <Chip Step info> for a summary on revision codes.
  2066.   See <General FPU bugs> for FPU bugs unrelated to instructions.
  2067.   See <FPU mnemonics> for FPU bugs related to FPU instructions.
  2068.   See <List of NEC mnemonics> for a list of NEC instructions.
  2069.   See <NEC general info> for a summary of special features in NECs.
  2070.  
  2071.  
  2072.   <AAA>     Adjust after addition      <AAD>    Adjust after division
  2073.   <AAM>     Adjust after multiply      <AAS>    Adjust after subtraction
  2074.   <BOUND>   Bounds check
  2075.   <BSF>     Bit scan forward           <BSWAP>  4-Byte swap (e-registers)
  2076.   <BT>      Bit test                   <BTC>    Bit test & complement
  2077.   <BTR>     Bit test & reset           <BTS>    Bit test & set
  2078.   <CHKIND>  Alias mnemonic for BOUND on NEC
  2079.  
  2080.   <CMPS> CMPSB CMPSW CMPSD  String compare, Byte, Word, Doubleword
  2081.  
  2082.   <CMPXCHG> Compare & exchange        <CPUID>   Identify CPU (486+)
  2083.  
  2084.   <CR0> CR1 CR2 CR3 CR4 Map of control registers
  2085.  
  2086.   <EFLAGS>  Map of EFLAGS register
  2087.  
  2088.   <HLT>     Halt the CPU              <IBTS>    Insert bit string
  2089.   <IMUL>    Integer multiply
  2090.  
  2091.   <INS> INSB INSW INSD Input of string from I/O port, Byte, Word, Doubleword
  2092.  
  2093.   <INVD>    Invalidate cache          <JMP>     Unconditional jump
  2094.   <LAR>     Load access rights        <LOADALL> Load all registers.
  2095.   <LSL>     Load segment limit        <MOV>     Move data to/from registers
  2096.   <MOVS>    Move string               <MUL>     Multiply unsigned
  2097.   <POP>     Pop data from stack       <POPA>    Pop all registers
  2098.   <PUSH>    Push value onto stack     <RDTSC>   Read time stamp counter
  2099.  
  2100.   <RDMSR>   Read Model Specific Register (Pentium+)
  2101.  
  2102.   <Rotate and Shift>   Concerns all Rotation and Shift instructions
  2103.  
  2104.   <SETALC>  Carry bit to all of al    <UNKNOWN> An unknown opcode
  2105.   <VERR>    Verify segment for Read   <VERW>    Verify segment for Write
  2106.  
  2107.   <WBINVD>  Write Back and Invalidate Cache (486+)
  2108.   <WRMSR>   Write Model Specific Register (Pentium+)
  2109.  
  2110.  
  2111.  
  2112.  
  2113. All mentioned FPU instructions by Mnemonic
  2114. ──────────────────────────────────────────────────────────────────────────────
  2115.  
  2116. Alphabetic listing on FPU Mnemonics for instructions behaving different
  2117. than expected. Instructions marked with * are considered undocumented.
  2118.  
  2119. * <FCOS>              FPU Cosine in radians on IIT math coprocessor
  2120.  
  2121.   <FDISI / FNDISI>    Disable Floating point interrupts
  2122.   <FDIV  /  FDIVP>    Divide
  2123.   <FDIVR / FDIVRP>    Divide reversed
  2124.   <FENI  /  FNENI>    Enable Floating point interrupts
  2125.  
  2126.   <FLDENV>            Load Floating point Environment
  2127.   <FMUL4X4>           Matrix multiply on IIT math coprocessor
  2128.   <FPREM>             Modulus of ST by ST(1) into ST
  2129.   <FPTAN>             Tangent ratio of ST into ST & ST(1)
  2130.   <FRSTPM>            Tells the FPU to use Real (or V86) Mode formats
  2131.   <FRSTOR>            Loads the FPU state from memory see FSAVE
  2132.   <FSAVE>             Saves the FPU state to memory see FRSTOR
  2133. * <FSBP0,1,2,3>       Bankswitching on IIT math coprocessor
  2134.   <FSCALE>            Adds the value in ST to the exponent in ST(1)
  2135.   <FSETPM>            Tells the FPU to use Protected Mode formats
  2136. * <FSIN>              FPU Sine in radians on IIT math coprocessor
  2137.   <FSINCOS>           calculates FPU sine and cosine in radians
  2138.   <FSTENV>            Store Floating point Environment
  2139.  
  2140.  
  2141.  
  2142.  
  2143. General Intel FPU bugs, unrelated to opcodes
  2144. ──────────────────────────────────────────────────────────────────────────────
  2145.  
  2146. Mnemonic: N/A
  2147. Opcode  : N/A
  2148. Bug in  : some 486 / 487
  2149.  
  2150. Function:
  2151. While using a maths coprocessor (also referred to as floating point
  2152. unit FPU), errors may occur and invalid numbers may be generated.
  2153. While most FPUs don't have any problem handling these situations, some
  2154. steps may lock up or misbehave otherwise. The list below shows known
  2155. malfunctions which may arise during FPU operations on some systems.
  2156.  
  2157.     True bugs:
  2158.     <FERR# not handled correctly by FPU>
  2159.     <FPU performance degradation because IGNNE# active>
  2160.  
  2161.     Incompatibilities between different types of FPU:
  2162.     <Four indications for 'empty' in Condition Code Bits after FXAM>
  2163.  
  2164.     '87 to 287 specific differences:
  2165.     <Error signal does not go through PIC on 287+>
  2166.     <Exceptions are different>
  2167.     <Exception pointers saved by 287+ save prefixes>
  2168.  
  2169.     <287+ need no synchronization>
  2170.     <287 & 387 use reserved I/O ports>
  2171.  
  2172.  
  2173.  
  2174.  
  2175. FERR# not handled correctly by FPU
  2176. ──────────────────────────────────────────────────────────────────────────────
  2177.  <Back> (General Intel FPU bugs, unrelated to opcodes)
  2178.  
  2179. * FERR# not handled correctly by FPU:
  2180.  
  2181.     In some cases an FPU operation may generate a floating point error,
  2182.     which will not be recognized by the CPU.
  2183.     The workaround for this is to replace all FWAIT with FNOP or follow
  2184.     all FWAIT with a NOP, while masking all floating point errors.
  2185.  
  2186.  
  2187.  
  2188.  
  2189. FPU performance degradation because IGNNE# active
  2190. ──────────────────────────────────────────────────────────────────────────────
  2191.  <Back> (General Intel FPU bugs, unrelated to opcodes)
  2192.  
  2193. * FPU performance degradation because IGNNE# active:
  2194.  
  2195.     If an unmasked exception occurs with bit NE (Numeric Error or Numeric
  2196.     Exception) in CR0 cleared (recognize exceptions), while IGNNE# is
  2197.     active, all following FPU instructions will require an additional 17 to
  2198.     22 clocks. This because the exception remains pending due to the logic
  2199.     conflict caused by contradicting signals. It lets the 486/487 execute
  2200.     microcode in order to classify and analyze the exception, but it does
  2201.     not let it handle it, prior to executing the next FPU opcode.
  2202.     A workaround is to clear all unmasked exceptions with FCLEX or FINIT
  2203.     within an exception handler before it finishes or to make sure IGNNE#
  2204.     is not made active so exceptions are recognized and handled immediately
  2205.     as they occur (when NE is cleared).
  2206.  
  2207.  
  2208.  
  2209.  
  2210. Four indications for 'empty' in Condition Code Bits after FXAM
  2211. ──────────────────────────────────────────────────────────────────────────────
  2212.  <Back> (General Intel FPU bugs, unrelated to opcodes)
  2213.  
  2214. * Four different indications for 'empty' in Condition Code Bits after FXAM:
  2215.  
  2216.     The various FPUs use different bit patterns to indicate an empty FPU
  2217.     register after the FXAM instruction. You should rely only on bits C0
  2218.     and C3 to be 1 in case an FPU register is to be considered empty.
  2219.     (See <FPU Condition Code Bits>)
  2220.  
  2221.  
  2222.  
  2223.  
  2224. Error signal does not go through PIC on 287+
  2225. ──────────────────────────────────────────────────────────────────────────────
  2226.  <Back> (General Intel FPU bugs, unrelated to opcodes)
  2227.  
  2228. * Error signal does not go through PIC on 287+
  2229.  
  2230.     On the 86, an FPU error is signalled through the PIC (Programmable
  2231.     Interrupt Controller). Starting with the 287, FPU errors are
  2232.     signalled over a dedicated pin on the CPU / FPU combination,
  2233.     namely ERROR#. There may be code which depends on the PIC handling
  2234.     the error. These error handlers will need to be rewritten.
  2235.  
  2236.  
  2237.  
  2238.  
  2239. Exceptions are different
  2240. ──────────────────────────────────────────────────────────────────────────────
  2241.  <Back> (General Intel FPU bugs, unrelated to opcodes)
  2242.  
  2243. * Exceptions are different
  2244.  
  2245.     The coprocessor segment overrun exception (09) is issued when the
  2246.     FPU attempts to read the second or subsequent words of a data
  2247.     operand beyond a segment limit on a 286. On a 386 it is not normally
  2248.     used. The 486 signals exception 0dh instead.
  2249.  
  2250.     The segment wraparound exception (General Protection exception 0dh)
  2251.     will be issued if the FPU attempts to execute an instruction that
  2252.     spans into or lies beyond a segment limit.
  2253.  
  2254.     All other errors are signalled through interrupt 10h in 286 systems.
  2255.  
  2256.  
  2257.  
  2258.  
  2259. Exception pointers saved by 287+ save prefixes
  2260. ──────────────────────────────────────────────────────────────────────────────
  2261.  <Back> (General Intel FPU bugs, unrelated to opcodes)
  2262.  
  2263. * Exception pointers saved by 287+ save prefixes
  2264.  
  2265.     The exception pointers on the 87 would point to the ESC instruction
  2266.     itself, regardless of any segment overrides (or other prefixes for
  2267.     that matter). The 287+ pointers point to the first prefix before
  2268.     the ESC instruction, if any.
  2269.  
  2270.  
  2271.  
  2272.  
  2273. 287+ need no synchronization
  2274. ──────────────────────────────────────────────────────────────────────────────
  2275.  <Back> (General Intel FPU bugs, unrelated to opcodes)
  2276.  
  2277. * 287+ need no synchronization
  2278.  
  2279.     On the 87, the FPU and CPU worked separated from each other. Any
  2280.     communication between the FPU and CPU had to be coordinated with
  2281.     WAITs. On the 287+, no WAITs are required except for control
  2282.     instructions. The CPU examines the BUSY# signal before communicating
  2283.     with the FPU to assure the FPU can accept commands.
  2284.  
  2285.     The 387 also examines BUSY# before sending commands to the FPU.
  2286.     Data transfers are regulated by monitoring the PEREQ# pin.
  2287.  
  2288.  
  2289.  
  2290.  
  2291. 287 & 387 use reserved I/O ports
  2292. ──────────────────────────────────────────────────────────────────────────────
  2293.  <Back> (General Intel FPU bugs, unrelated to opcodes)
  2294.  
  2295. * 287 & 387 use reserved I/O ports
  2296.  
  2297.     On the 287, FPU instructions and data are sent to and received from
  2298.     the FPU via I/O ports. These ports are f0-ff on the 286 / 287.
  2299.     This property is important to consider when the number of I/O
  2300.     waitstates on the mainboard can be changed. To safely increase the
  2301.     FPU performance some experimentation may be necessary, but a 25%
  2302.     speed increase has been accomplished on a 12 MHz 286 with 20 MHz
  2303.     IIT 2c87 by decreasing the number of I/O waitstates from 6 to 4.
  2304.  
  2305.     On the 387, FPU instructions and data are sent to and received from
  2306.     the FPU via I/O ports too. These ports are 800000f0 - 800000ff.
  2307.     Note that the I/O waitstate trick may very well work on 386 / 387
  2308.     systems as well.
  2309.  
  2310.  
  2311.  
  2312.  
  2313. FPU Condition Code Bits after a test, compare or reduction
  2314. ──────────────────────────────────────────────────────────────────────────────
  2315.  
  2316. Vatious FPU test instructions set the Condition Code bits C0 to C3 based
  2317. on the values tested. Below is a list of possible bit combinations.
  2318.  
  2319. These C-bits map to the flags register as follows after stswax and sahf:
  2320.  
  2321. Eflags map: ZF  PF  -   CF  (C1 has no flag assigned to it)
  2322.             C3  C2  C1  C0
  2323.  
  2324. Examine     0   0   0   0   +Unnormal (positive, valid, unnormalized)
  2325.             0   0   0   1   +NaN      (positive, invalid, exponent is 0)
  2326.             0   0   1   0   -Unnormal (negative, valid, unnormalized)
  2327.             0   0   1   1   -NaN      (negative, invalid, exponent is 0)
  2328.             0   1   0   0   +Normal   (positive, valid, normalized)
  2329.             0   1   0   1   +Infinity (positive, infinity)
  2330.             0   1   1   0   -Normal   (negative, valid, normalized)
  2331.             0   1   1   1   -Infinity (negative, infinity)
  2332.             1   0   0   0   +Zero     (positive, zero)
  2333.             1   0   0   1   Empty     (empty register)
  2334.             1   0   1   0   -Zero     (negative, zero)
  2335.             1   0   1   1   Empty     (empty register)
  2336.             1   1   0   0   +Denormal (positive, invalid, exponent is 0)
  2337.             1   1   0   1   Empty     (empty register)
  2338.             1   1   1   0   -Denormal (negative, invalid, exponent is 0)
  2339.             1   1   1   1   Empty     (empty register)
  2340.  
  2341. FCOM or
  2342. STST        0   0   ?   0   ST > Source with FCOM or ST > 0 with FSTST
  2343.             0   0   ?   1   ST < Source with FCOM or ST < 0 with FSTST
  2344.             1   0   ?   0   ST = Source with FCOM or ST = 0 with FSTST
  2345.             1   1   ?   1   ST cannot be compared ot tested
  2346.  
  2347. Reduction   b1  0   b0  b2  If reduction was complete, bits 0,1 and 2
  2348.                             equal the three lowest bits of the qoutient
  2349.             ?   1   ?   ?   Reduction was incomplete
  2350.  
  2351.  
  2352.  
  2353.  
  2354. FPU Status Word, Control Word and Tag Word layout
  2355. ──────────────────────────────────────────────────────────────────────────────
  2356.  
  2357. The layout of the Status-, Control- and Tag Word of the FPU.
  2358.  
  2359.       FPU Status Word
  2360.  
  2361.       Bit 15                8                        0
  2362.       ┌──┬──┬──┬──┼──┬──┬──┬──┼──┬──┬──┬──┼──┬──┬──┬─┴┐
  2363.       │ B│c3│  ST n  │c2│c1│c0│ES│sf│Pe│Ue│Oe│Ze│De│Ie│
  2364.       └─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┘
  2365.         │  │  └──┼──┘  └──┼──┘  │  │  │  │  │  │  │  │
  2366.       Busy ╘═════╪════════╡     │  │  │  │  │  │  │  │
  2367.       Stack Top──┘        │     │  │  │  │  │  │  │  │
  2368.       Condition Code Bits─┘     │  │  │  │  │  │  │  │
  2369.       Exception Summary * ──────┘  │  │  │  │  │  │  │
  2370.       Stack fault──────────────────┘  │  │  │  │  │  │
  2371.       Precision exception (1=occurred)┘  │  │  │  │  │
  2372.       Underflow exception (1=occurred)───┘  │  │  │  │
  2373.       Overflow exception (1=occurred)───────┘  │  │  │
  2374.       Zero divison exception (1=occurred)──────┘  │  │
  2375.       Denormalized operand exception (1=occurred)─┘  │
  2376.       Invalid operation exception (1=occurred)───────┘
  2377.  
  2378.       * The Exception summary is called Interrupt request on 8087.
  2379.  
  2380.       FPU Control Word
  2381.  
  2382.       Bit 15                8                        0
  2383.       ┌──┬──┬──┬──┼──┬──┬──┬──┼──┬──┬──┬──┼──┬──┬──┬─┴┐
  2384.       │ r│ r│ r│ic│round│prec.│ie│ r│Pm│Um│Om│Zm│Dm│Im│
  2385.       └──┴──┴──┴─┼┴──┴─┼┴─┼┴──┴─┼┴──┴─┼┴─┼┴─┼┴─┼┴─┼┴─┼┘
  2386.       Infinity   │     │  │     │     │  │  │  │  │  │
  2387.       control────┘     │  │     │     │  │  │  │  │  │
  2388.       Rounding control─┘  │     │     │  │  │  │  │  │
  2389.       Precision control───┘     │     │  │  │  │  │  │
  2390.       Interrupt enable mask─────┘     │  │  │  │  │  │
  2391.                                       └┐ │  │  │  │  │
  2392.       Precision exception Mask 1=masked┘ │  │  │  │  │
  2393.       Underflow exception Mask 1=masked──┘  │  │  │  │
  2394.       Overflow exception Mask 1=masked──────┘  │  │  │
  2395.       Zero divison exception Mask 1=masked─────┘  │  │
  2396.       Denormalized operand exception Mask 1=masked┘  │
  2397.       Invalid operation exception Mask 1=masked──────┘
  2398.  
  2399.     Infinity control is supported on the 8087 and 287 only.
  2400.     The 87 and 287 (not the 287xl) have ic cleared by default and then
  2401.     support projective closure. The 287xl+ only support affine closure.
  2402.     To make sure an 87 or 287 will handle the numbers in the same way
  2403.     as the 287xl+, set bit ic to make 87 & 287 support affine closure
  2404.     as well. Note that a FINIT will clear ic again.
  2405.     The ic setting is ignored on 287xl+.
  2406.  
  2407.     Rounding control is set to 00 by default.
  2408.     00 = Round to nearest or even
  2409.     01 = Round down (towards negative infinity)
  2410.     10 = Round up (towards positive infinity)
  2411.     11 = Chop towards zero
  2412.  
  2413.     Precision control is set to 11 by default.
  2414.     00 = 24 bit precision (mantissa)
  2415.     01 = reserved
  2416.     10 = 53 bit precision (mantissa)
  2417.     11 = 64 bit precision (mantissa)
  2418.  
  2419.     Note: lesser precision does not significantly reduce execution time.
  2420.  
  2421.  
  2422.       FPU Tag Word
  2423.  
  2424.       Bit 15                8                        0
  2425.       ┌──┬──┬──┬──┼──┬──┬──┬──┼──┬──┬──┬──┼──┬──┬──┬─┴┐
  2426.       │ x  x│ x  x│ x  x│ x  x│ x  x│ x  x│ x  x│ x  x│
  2427.       └──┴─┼┴──┴─┼┴──┴─┼┴──┴─┼┴──┴─┼┴──┴─┼┴──┴─┼┴──┴─┼┘
  2428.            7     6     5     4     3     2     1     0 Tag number
  2429.  
  2430.       The tag number 0 corresponds to the register which is
  2431.       currently ST0.
  2432.       The bits for each tag have the same meaning:
  2433.  
  2434.        0  0  Valid
  2435.        0  1  Zero
  2436.        1  0  Special (NaN,Infinity,Denormal,Unnormal,Unsupported)
  2437.        1  1  Empty
  2438.  
  2439.  
  2440.  
  2441.  
  2442. IIT bankswitching  (IIT math coprocessor)
  2443. ──────────────────────────────────────────────────────────────────────────────
  2444.  
  2445. Mnemonic: FSBP0, FSBP1, FSBP2, FSBP3
  2446. Opcode  : DB E8, DB Eb, EB EA, DB E9  (6 clocks)
  2447. Bug in  : Are IIT 2c87+ instructions
  2448.  
  2449. Function:
  2450. FSBP0 Selects the original bank. (default)
  2451. FSBP1 Selects bank 1 from <FMUL4X4> instruction diagram
  2452. FSBP2 Selects bank 2 from FMUL4X4 instruction diagram
  2453. FSBP3 Selects the scratchpad bank3 used by the FMUL4X4 internally.
  2454.  
  2455. The FSBP3 instruction is not publicly supported by IIT, it can be used to
  2456. select the last bank of registers, which unfortunately cannot be used for
  2457. regular operation. However, it is listed for completeness.
  2458.  
  2459.  
  2460.  
  2461.  
  2462. FSIN / FCOS   Floating point sine and cosine
  2463. ──────────────────────────────────────────────────────────────────────────────
  2464.  
  2465. Mnemonic: FSIN  / FCOS
  2466. Opcode  : D9 FE / D9 FF
  2467. Bug in  : Undocumented instructions on IIT 2c87 math chips
  2468.  
  2469. Function:
  2470. FSIN calculates the radial sine of the value in ST(0), leaving the result
  2471. in ST(0). Apparently the IIT FSIN functions according to Intel's 287xl
  2472. and 387+ specifications.
  2473.  
  2474. FCOS calculates the radial cosine of the value in ST(0), leaving the result
  2475. in ST(0). Apparently the IIT FCOS functions according to Intel's 287xl
  2476. and 387+ specifications.
  2477.  
  2478. Both these instructions are not officially supported by IIT for the 2c87.
  2479. Both instructions are available on Intel 287xl and 387+ processors using the
  2480. listed opcodes.
  2481.  
  2482.  
  2483.  
  2484.  
  2485. FDIV / FDIVP  Floating point division / divide & POP
  2486. ──────────────────────────────────────────────────────────────────────────────
  2487.  
  2488. Mnemonic: FDIV / FDIVP
  2489. Opcode  : various
  2490. Bug in  : some 486
  2491.  
  2492. Function:
  2493. FDIV divides destination by source and returns the result in destination.
  2494. FDIVP does the same but pops the FPU stack afterwards.
  2495.  
  2496. The bug occurs when the instruction operates on an FPU register which is
  2497. tagged as empty, but holds a nonzero value and the next FPU instruction
  2498. occurs within 35 FPU clock counts. In that case, the current instruction
  2499. will use the invalid number in the empty location, producing an invalid
  2500. result and causing the following instruction to generate an invalid
  2501. result as well. There is no workaround.
  2502.  
  2503.  
  2504.  
  2505.  
  2506. FDIVR / FDIVRP  Floating point division reversed / divide & POP
  2507. ──────────────────────────────────────────────────────────────────────────────
  2508.  
  2509. Mnemonic: FDIVR / FDIVRP
  2510. Opcode  : various
  2511. Bug in  : some 486
  2512.  
  2513. Function:
  2514. FDIVR divides source by destination and returns the result in destination.
  2515. FDIVRP does the same but pops the FPU stack afterwards.
  2516.  
  2517. The bug occurs when the instruction operates on an FPU register which is
  2518. tagged as empty, but holds a nonzero value and the next FPU instruction
  2519. occurs within 35 FPU clock counts. In that case, the current instruction
  2520. will use the invalid number in the empty location, producing an invalid
  2521. result and causing the following instruction to generate an invalid
  2522. result as well. There is no workaround.
  2523.  
  2524.  
  2525.  
  2526.  
  2527. FLDENV  Load Floating point Environment
  2528. ──────────────────────────────────────────────────────────────────────────────
  2529.  
  2530. Mnemonic: FLDENV
  2531. Opcode  : D9 [mod:100:r/m] disp
  2532. Bug in  : some 387
  2533.  
  2534. Function:
  2535. FLDENV loads the entire FPU environment from the address given by the
  2536. memory operand. See <FPU environment layout>.
  2537.  
  2538. If either of the two last bytes of the environment cannot be read for
  2539. whatever reason, the instruction cannot be restarted on some 387s.
  2540.  
  2541. A workaround is to attempt to read those bytes before the FLDENV is
  2542. executed or to align the environment on a 128 byte boundary so it is
  2543. unlikely to fall outside a segment or page boundary.
  2544. Should that be the case, the integer unit can cause an exception or
  2545. make sure the page (in case of a swapped page) is read into memory
  2546. before FLDENV starts.
  2547.  
  2548.  
  2549.  
  2550.  
  2551. FMUL4X4 Matrix Multiply (IIT math coprocessor)
  2552. ──────────────────────────────────────────────────────────────────────────────
  2553.  
  2554. Mnemonic: FMUL4X4 or F4X4
  2555. Opcode  : DB F1  (2c87=242, 3c87sx=242, 3c87=242 clocks)
  2556. Bug in  : Is an IIT special instruction
  2557.  
  2558. Function:
  2559. This instruction is available only on the IIT (Integrated Information
  2560. Technology Inc.) math processors. The instruction performs a 4x4 matrix
  2561. multiply in one instruction using three banks of 8 floating point registers.
  2562. The operands must be loaded to a specific bank in a specific order using
  2563.  
  2564. Xn = (A00 * Xo) + (A01 * Xo) + (A02 * Xo) + (A03 * Xo)
  2565. Yn = (A10 * Yo) + (A11 * Yo) + (A12 * Yo) + (A13 * Yo)
  2566. Zn = (A20 * Zo) + (A21 * Zo) + (A22 * Zo) + (A23 * Zo)
  2567. Vn = (A30 * Vo) + (A31 * Vo) + (A32 * Vo) + (A33 * Vo)
  2568.  
  2569. Where Xo stands for the original X value and Xn for the result. Operands
  2570. must be loaded to the following registers in the specified banks in the
  2571. specified order.
  2572.  
  2573.           Before FMUL4X4             After FMUL4X4
  2574.  
  2575.                    bank              bank
  2576.           Register: 0    1    2      0
  2577.  
  2578.           ST(0)     Xo   A33  A31    Xn
  2579.           ST(1)     Yo   A23  A21    Yn
  2580.           ST(2)     Zo   A13  A11    Zn
  2581.           ST(3)     Vo   A03  A01    Vn
  2582.           ST(4)          A32  A30     ?
  2583.           ST(5)          A22  A20     ?
  2584.           ST(6)          A12  A10     ?
  2585.           ST(7)          A02  A00     ?
  2586.  
  2587. All four banks can be selected by using the bankswitching instructions,
  2588. but only bank 0, 1 and 2 make sense since bank 3 is an internal scratchpad.
  2589. The separate banks can contain 8 floating point numbers and may be used
  2590. with normal instructions. Each bank acts like an independent 287.
  2591. Provided the status of the status word is saved inbetween and restored
  2592. properly after a bankswitch each bank can be used simultaneously.
  2593.  
  2594. Alternatively you could keep an eye on the TOP and STACKPOINTER indicators,
  2595. making sure they are the same as before when initiating a bankswitch.
  2596. By using FFREE, FFREEP and FINCSTP or FDECSTP instructions you may manually
  2597. manipulate the stack.
  2598.  
  2599. This feature of the IIT chips can be used to perform complex operations
  2600. in registers with many components remaining the same for a large dataset,
  2601. only saving intermediary results to one memory location, bankswitching 
  2602. to the next series of operands, loading that one operand and continuing the
  2603. calculation with the next set of operands already in that bank. This does
  2604. require another read into the new bank but may save time and memoryspace
  2605. compared to memory based operands or multiple pass algorithms with multiple
  2606. arrays of intermediary results.
  2607.  
  2608.  
  2609.  
  2610.  
  2611. FENI / FDISI  Enable /Disable Floating point interrupts
  2612. ──────────────────────────────────────────────────────────────────────────────
  2613.  
  2614. Mnemonic: FENI     / FNENI / FDISI    / FNDISI
  2615. Opcode  : 9B DB E0 / DB E0 / 9B DB E1 / DB E1
  2616. Bug in  : Opcodes have no meaning on 287+ (are ignored there)
  2617.  
  2618. Function:
  2619. FENI Clears the interrupt enable mask in the FPU Control Word, effectively
  2620. allowing the FPU to generate interrupts. FNENI does not issue a WAIT
  2621. before doing this. These instruction only have a meaning on 87s.
  2622.  
  2623. FDISI Sets the interrupt enable mask in the FPU Control Word, effectively
  2624. denying the FPU to generate interrupts. FNDISI does not issue a WAIT
  2625. before doing this. These instruction only have a meaning on 87s.
  2626.  
  2627. All these instructions are effectively ignored on the 287+.
  2628. They do not cause an invalid opcode exception.
  2629.  
  2630.  
  2631.  
  2632.  
  2633. FPREM  Calculate modulus of ST by ST(1), store in ST
  2634. ──────────────────────────────────────────────────────────────────────────────
  2635.  
  2636. Mnemonic: FPREM
  2637. Opcode  : D9 F8
  2638. Bug in  : all 87 and 287
  2639.  
  2640. Function:
  2641. FPREM calculates the modulus remainder of ST divided by ST(1) and stores
  2642. the result into ST. The procedure can also be seen as a repeated
  2643. subtraction of ST by ST(1).
  2644.  
  2645. There are several interesting things about this instruction:
  2646.  
  2647. The exponent magnitude difference should be no more than 63 or else the
  2648. instruction cannot reduce the ST properly in one execution. This means
  2649. you would have to execute the instruction several times to get a correct
  2650. result for large magnitude differences.
  2651. If this is the case, condition code bit C2 is set until the result in ST
  2652. is ok. Storing the Status Word and checking C2 should be done if the
  2653. condition could occur in your data set.
  2654.  
  2655. In addition to that, if the instruction is done, the least-significant
  2656. three bits of the quotient are stored in C3,C1 and C0.
  2657. If arguments to the tangent function are reduced by PI/4 the codes
  2658. represent one of the eight octants of a radius for which the tangent is
  2659. to be calculated.
  2660.  
  2661. FPREM does not operate according to the IEEE 754 standard, FPREM1
  2662. with opcode d9 f5 does, but is about 15-25 clocks slower than FPREM.
  2663.  
  2664. The bug appears on the 87 and 287 when 64^a+b is performed with a>=1
  2665. and b==1 or 2. In that case the condition code bits represent an
  2666. incorrect value. There is no FP workaround. Test to prevent the situation.
  2667. Apparently this bug does not appear in the FPREM1 instruction.
  2668.  
  2669.  
  2670.  
  2671.  
  2672. FPTAN  Calculate tangent of ST
  2673. ──────────────────────────────────────────────────────────────────────────────
  2674.  
  2675. Mnemonic: FPTAN
  2676. Opcode  : D9 F2
  2677. Bug in  : some 486 / 487, difference between pre-287xls and 287xl+
  2678.  
  2679. Function:
  2680. FPTAN calculates the ratio between x and y in the following formula:
  2681.  
  2682.    x
  2683.    -  = TAN(original ST)
  2684.    y
  2685.  
  2686. The y result replaces the original argument in ST and x is then pushed
  2687. onto the stack. On pre-287xl FPUs, the values for y and x may be anything,
  2688. the ratio however is correct. On 287xl+ FPUs, x is always 1.
  2689. ST(1) represents the fractional value itself there.
  2690. To generate the same set of results on all FPUs, the FPTAN should be
  2691. followed by FDIV and FLD1. Note that this reproduces the original
  2692. results on the 287xl+.
  2693.  
  2694. Note that ST(7) must be free or an invalid operation exception may occur
  2695. because x is pushed onto the stack.
  2696.  
  2697. The 486 bug occurs when a specific set of code is executed with a specific
  2698. set of data. There is no way you can anticipate this and the workaround
  2699. should always be implemented if code will run on a 486/487.
  2700. The bug corrupts the FPU stack without signalling it to either FPU or CPU.
  2701. Data corruption is usually the result.
  2702. Workaround: FPTAN should always be followed by: FCLEX, FINIT, FLDCW, FSTSW,
  2703. FSTSWAX, <FSAVE> or <FSTENV> or by a WAIT and a non-FPU instruction.
  2704. Do note that some of these FPU instructions contain bugs themselves.
  2705.  
  2706.  
  2707.  
  2708.  
  2709. FRSTOR  Restore FPU state saved to memory by FSAVE
  2710. ──────────────────────────────────────────────────────────────────────────────
  2711.  
  2712. Mnemonic: FRSTOR
  2713. Opcode  : DB [mod:100:r/m] disp
  2714. Bug in  : some 387
  2715.  
  2716. Function:
  2717. FRSTOR loads the FPU internal registers (including ST-registers) and the
  2718. environment from the memory operand. See <FPU State image layout>.
  2719.  
  2720. If either of the two last bytes of the image being read by FRSTOR cannot
  2721. be read for whatever reason, the instruction cannot be restarted on
  2722. some 387s.
  2723.  
  2724. A workaround is to attempt to read those bytes before the FRSTOR is
  2725. executed or to align the image on a 128 byte boundary so it is
  2726. unlikely to fall outside a segment or page boundary.
  2727. Should that be the case, the integer unit can cause an exception or
  2728. make sure the page (in case of a swapped page) is read into memory
  2729. before FRSTOR starts.
  2730.  
  2731.  
  2732.  
  2733.  
  2734. FSAVE  Save FPU state to memory
  2735. ──────────────────────────────────────────────────────────────────────────────
  2736.  
  2737. Mnemonic: FSAVE / FNSAVE
  2738. Opcode  : (9B) DB [mod:110:r/m] disp
  2739. Bug in  : some 387, some 386
  2740.  
  2741. Function:
  2742. FSAVE saves the FPU internal registers (including ST-registers) and the
  2743. environment to the memory operand. See <FPU State image layout>.
  2744.  
  2745. The FPU does not execute this instruction until all pending FPU
  2746. operations have completed (decoded instructions have been processed).
  2747. After completion, FSAVE initializes the FPU as if it had executed FINIT.
  2748.  
  2749. Apparently on all FPUs, the contents of the data pointer field is
  2750. undefined if the last FPU arithmetic instruction did not use a memory
  2751. operand.
  2752.  
  2753. On some 386s operating in Real or V86 mode, the opcode saved is incorrect.
  2754. The linear address saved for the opcode's address however is correct and
  2755. can be used to retrieve the opcode. No opcode is saved in Protected mode.
  2756.  
  2757. If either of the two last bytes of the image being saved by FSAVE cannot
  2758. be accessed for whatever reason, the instruction cannot be restarted on
  2759. some 387s.
  2760.  
  2761. A workaround is to attempt to write to those bytes before the FSAVE is
  2762. executed or to align the image on a 128 byte boundary so it is
  2763. unlikely to fall outside a segment or page boundary.
  2764. Should that be the case, the integer unit can cause an exception or
  2765. make sure the page (in case of a swapped page) is read into memory
  2766. before FSAVE starts.
  2767.  
  2768.  
  2769.  
  2770.  
  2771. FSETPM  Make FPU use Protected Mode format in FSAVE and FSTENV
  2772. ──────────────────────────────────────────────────────────────────────────────
  2773.  
  2774. Mnemonic: FSETPM
  2775. Opcode  : DB E4
  2776. Bug in  : no bug, it only works on 287 and 287xl. ignored on 386+
  2777.  
  2778. Function:
  2779. FSETPM tells the FPU to use the data format specified in the Protected
  2780. Mode format of the <FSTENV> and <FSAVE> instructions.
  2781. These instructions save different types of data depending on the current
  2782. operating mode of the FPU.
  2783.  
  2784. The instruction only has a meaning on the 287 and 287xl.
  2785.  
  2786.  
  2787.  
  2788.  
  2789. FRSTPM  Make FPU use Real-Mode format in FSAVE and FSTENV
  2790. ──────────────────────────────────────────────────────────────────────────────
  2791.  
  2792. Mnemonic: FRSTPM
  2793. Opcode  : DB F4
  2794. Bug in  : no bug, it only works on 287 and 287xl. ignored on 386+
  2795.  
  2796. Function:
  2797. FRSTPM tells the FPU to use the data format specified in the Real-Mode
  2798. format of the <FSTENV> and <FSAVE> instructions.
  2799. These instructions save different types of data depending on the current
  2800. operating mode of the FPU.
  2801.  
  2802. The instruction only has a meaning on the 287 and 287xl.
  2803.  
  2804.  
  2805.  
  2806.  
  2807. FSCALE  Adds the integer number in ST(1) to the exponent of ST
  2808. ──────────────────────────────────────────────────────────────────────────────
  2809.  
  2810. Mnemonic: FSCALE
  2811. Opcode  : D9 FD
  2812. Bug in  : some 486
  2813.  
  2814. Function:
  2815. FSCALE multiplies the value in ST by a power of two, given in ST(1).
  2816. Pre-387s assume the value in ST(1) to be an integer in the range
  2817. -2^15 <= , < +2^15. 387+ do not assume anything about the value.
  2818. The value in ST(1) is always chopped to the nearest integer closest
  2819. to zero.
  2820.  
  2821. There is a bug in some 486s which allows denormal or pseudo-denormals to
  2822. be returned as a result, apparently without issuing an Invalid Operation
  2823. exception. For this to happen, ST(1) must be within the range
  2824. -1 < ST(1) < 1 and ST must be a pseudo-denormal or denormal while
  2825. underflow exceptions must not be masked. When it occurs, the value from
  2826. ST is returned as the result.
  2827.  
  2828. There is no workaround other than to avoid the situation. Leaving
  2829. underflow exceptions masked may prevent this bug from showing up.
  2830.  
  2831.  
  2832.  
  2833.  
  2834. FSINCOS  Calculate both Sine and Cosine of ST
  2835. ──────────────────────────────────────────────────────────────────────────────
  2836.  
  2837. Mnemonic: FSINCOS
  2838. Opcode  : DB FB
  2839. Bug in  : some 486, invalid on pre-287xl and IIT
  2840.  
  2841. Function:
  2842. FSINCOS calculates both Sine and Cosine of an argument in ST.
  2843. The first result, sine, is stored into the original ST, destroying the
  2844. source value. The second result, cosine, is then pushed onto the stack.
  2845.  
  2846. Note that ST(7) must be free or an invalid operation exception may occur
  2847. because the cosine is pushed onto the stack.
  2848.  
  2849. The 486 bug occurs when a specific set of code is executed with a specific
  2850. set of data. There is no way you can anticipate this and the workaround
  2851. should always be implemented if code will run on a 486/487.
  2852. The bug corrupts the FPU stack without signalling it to either FPU or CPU.
  2853. Data corruption is usually the result.
  2854. Workaround: FSINCOS should always be followed by: FCLEX, FINIT, FLDCW,
  2855. FSTSW, FSTSWAX, <FSAVE> or <FSTENV> or by a WAIT
  2856. and a non-FPU instruction. Do note that some of these FPU instructions
  2857. contain bugs themselves.
  2858.  
  2859.  
  2860.  
  2861.  
  2862. FSTENV  Store Floating point Environment
  2863. ──────────────────────────────────────────────────────────────────────────────
  2864.  
  2865. Mnemonic: FSTENV
  2866. Opcode  : (9B) D9 [mod:110:r/m] disp
  2867. Bug in  : some 386
  2868.  
  2869. Function:
  2870. FSTENV saves the FPU environment to the memory operand.
  2871. See <FPU environment image layout>.
  2872. This environment does not include the FPU stack, but does include
  2873. Control Word, Status Word, Tag Word and exception pointers.
  2874.  
  2875. The FPU does not execute this instruction until all pending FPU
  2876. operations have completed (decoded instructions have been processed).
  2877. After completion, FSTENV initializes the FPU as if it had executed FINIT.
  2878.  
  2879. Apparently on all FPUs, the contents of the data pointer field is
  2880. undefined if the last FPU arithmetic instruction did not use a memory
  2881. operand.
  2882.  
  2883. On some 386s operating in Real or V86 mode, the opcode saved is incorrect.
  2884. The linear address saved for the opcode's address however is correct and
  2885. can be used to retrieve the opcode. No opcode is saved in Protected mode.
  2886.  
  2887. If either of the two last bytes of the image being saved by FSTENV cannot
  2888. be accessed for whatever reason, the instruction cannot be restarted on
  2889. some 387s.
  2890.  
  2891. A workaround is to attempt to write to those bytes before the FSTENV is
  2892. executed or to align the image on a 128 byte boundary so it is
  2893. unlikely to fall outside a segment or page boundary.
  2894. Should that be the case, the integer unit can cause an exception or
  2895. make sure the page (in case of a swapped page) is read into memory
  2896. before FSTENV starts.
  2897.  
  2898.  
  2899.  
  2900.  
  2901. Layout of environment & state stored by FSTENV and FSAVE
  2902. ──────────────────────────────────────────────────────────────────────────────
  2903.  
  2904. The environment area saved by <FSTENV> and loaded by <FLDENV> depends on the
  2905. current operating mode of the FPU. Apart from the mode, the current
  2906. default addressing mode within the operating mode is also important.
  2907.  
  2908. The state information saved by <FSAVE> and loaded by <FRSTOR>
  2909. consists of the environment mentioned above but also has the eight FPU
  2910. stack registers appended to it in temporary real format starting with the
  2911. current ST register. Note that which register represents ST depends on
  2912. the values in the Control Word.
  2913.  
  2914. There are four states in which the 387+ FPU can operate
  2915.  
  2916.   16-bit real or V86 mode (like in DOS)
  2917.   16-bit Protected Mode (16-bit code segment)
  2918.   32-bit real or V86 mode (using 66h and 67h prefixes)
  2919.   32-bit Protected Mode (32-bit code segment)
  2920.  
  2921.         16-bit real or V86 mode:
  2922.  
  2923.     15     12      8       4       0
  2924.     ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┐
  2925.     │d│d│d│d│0│0│0│0│0│0│0│0│0│0│0│0│ d = Data pointer bits 16 - 19
  2926.     ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤
  2927.     │ Data pointer bits 0-15        │
  2928.     ├─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┤     bit 11 is zero, not a typo.
  2929.     │i│i│i│i│0│o│o│o│o│o│o│o│o│o│o│o│ i = Instruction pointer bits 16 - 19
  2930.     ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ o = Opcode highest 11 bits
  2931.     │ Instruction pointer bits 0-15 │
  2932.     ├───────────────────────────────┤
  2933.     │ Tag Word (16 bit)             │
  2934.     ├───────────────────────────────┤
  2935.     │ Status Word (16 bit)          │
  2936.     ├───────────────────────────────┤
  2937.     │ Control Word (16 bit)         │ Low memory
  2938.     └───────────────────────────────┘
  2939.  
  2940.  
  2941.  
  2942.         16-bit Protected Mode:
  2943.  
  2944.     15     12      8       4       0
  2945.     ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┐
  2946.     │ Data selector                 │
  2947.     ├───────────────────────────────┤
  2948.     │ Data offset                   │
  2949.     ├───────────────────────────────┤
  2950.     │ Instruction selector          │
  2951.     ├───────────────────────────────┤
  2952.     │ Instruction offset            │
  2953.     ├───────────────────────────────┤
  2954.     │ Tag Word (16 bit)             │
  2955.     ├───────────────────────────────┤
  2956.     │ Status Word (16 bit)          │
  2957.     ├───────────────────────────────┤
  2958.     │ Control Word (16 bit)         │ Low memory
  2959.     └───────────────────────────────┘
  2960.  
  2961.  
  2962.  
  2963.         32-bit Real Mode:
  2964.  
  2965.     31     28      24      20       15     12       8       4       0
  2966.     ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┬┴┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┐
  2967.     │0│0│0│0│  Data pointer bits 16-31      │0│0│0│0│0│0│0│0│0│0│0│0│
  2968.     ├─┴─┴─┴─┼───────────────────────┼───────┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤
  2969.     │- - - - - - - - - - - - - - - -│ Data pointer bits 0-15        │
  2970.     ├─┬─┬─┬─┼───────────────────────┼───────┼─┼─────────────────────┤
  2971.     │0│0│0│0│ Instruction pointer bits 16-31│0│ Opcode top 11 bits  │
  2972.     ├─┴─┴─┴─┴───────────────────────┼───────┴─┴─────────────────────┤
  2973.     │- - - - - - - - - - - - - - - -│ Instruction pointer 0-15      │
  2974.     ├───────────────────────────────┼───────────────────────────────┤
  2975.     │- - - - - - - - - - - - - - - -│ Tag Word (16 bit)             │
  2976.     ├───────────────────────────────┼───────────────────────────────┤
  2977.     │- - - - - - - - - - - - - - - -│ Status Word (16 bit)          │
  2978.     ├───────────────────────────────┼───────────────────────────────┤
  2979.     │- - - - - - - - - - - - - - - -│ Control Word (16 bit)         │
  2980.     └───────────────────────────────┴───────────────────────────────┘
  2981.                                                           Low memory
  2982.  
  2983.  
  2984.         32-bit Protected Mode:
  2985.  
  2986.     31     28      24      20       15     12       8       4       0
  2987.     ┌─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┬┴┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬─┼─┬─┬─┬┴┐
  2988.     │- - - - - - - - - - - - - - - -│ Data selector                 │
  2989.     ├───────────────────────────────┼───────────────────────────────┤
  2990.     │                      Data offset (32-bit)                     │
  2991.     ├───────────────────────────────┼───────────────────────────────┤
  2992.     │- - - - - - - - - - - - - - - -│ Instruction selector          │
  2993.     ├───────────────────────────────┼───────────────────────────────┤
  2994.     │                  Instruction offset (32-bit)                  │
  2995.     ├───────────────────────────────┼───────────────────────────────┤
  2996.     │- - - - - - - - - - - - - - - -│ Tag Word (16 bit)             │
  2997.     ├───────────────────────────────┼───────────────────────────────┤
  2998.     │- - - - - - - - - - - - - - - -│ Status Word (16 bit)          │
  2999.     ├───────────────────────────────┼───────────────────────────────┤
  3000.     │- - - - - - - - - - - - - - - -│ Control Word (16 bit)         │
  3001.     └───────────────────────────────┴───────────────────────────────┘
  3002.                                                           Low memory
  3003.  
  3004.      - = Don't care.
  3005.